aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-02-07 16:18:02 +0000
committersin <sin@2f30.org>2014-02-07 16:18:02 +0000
commit76b2240e1587129d4baefaffb738332440e20290 (patch)
treeee353c0eddeda2523067b91e62026a818db94c5c
parentb8cb53193c0d235cec99d70bb63838f27c3c5fda (diff)
Poweroff on SIGUSR1
-rw-r--r--sinit.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sinit.c b/sinit.c
index eff6533..35579d7 100644
--- a/sinit.c
+++ b/sinit.c
@@ -25,13 +25,15 @@ typedef struct {
void (*func)(void);
} Sigmap;
+static void sigpoweroff(void);
static void sigreap(void);
static void sigreboot(void);
static void spawn(const Arg *);
static Sigmap dispatchsig[] = {
- { SIGCHLD, sigreap },
- { SIGINT, sigreboot },
+ { SIGUSR1, sigpoweroff },
+ { SIGCHLD, sigreap },
+ { SIGINT, sigreboot },
};
static int sigfd = -1;
@@ -85,6 +87,12 @@ main(void)
}
static void
+sigpoweroff(void)
+{
+ spawn(&(Arg){ .v = rcpoweroffcmd });
+}
+
+static void
sigreap(void)
{
while (waitpid(-1, NULL, WNOHANG) > 0)