aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h6
-rw-r--r--sinit.c19
2 files changed, 10 insertions, 15 deletions
diff --git a/config.def.h b/config.def.h
index 75b2329..c689987 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */
-static const char *rcinitcmd[] = { "/bin/rc.init", NULL };
-static const char *rcrebootcmd[] = { "/bin/rc.shutdown", "reboot", NULL };
-static const char *rcpoweroffcmd[] = { "/bin/rc.shutdown", "poweroff", NULL };
+static char *const rcinitcmd[] = { "/bin/rc.init", NULL };
+static char *const rcrebootcmd[] = { "/bin/rc.shutdown", "reboot", NULL };
+static char *const rcpoweroffcmd[] = { "/bin/rc.shutdown", "poweroff", NULL };
diff --git a/sinit.c b/sinit.c
index c18146b..4939bc5 100644
--- a/sinit.c
+++ b/sinit.c
@@ -14,10 +14,6 @@
#include <unistd.h>
#include "util.h"
-typedef union {
- const void *v;
-} Arg;
-
typedef struct {
int sig;
void (*func)(void);
@@ -26,7 +22,7 @@ typedef struct {
static void sigpoweroff(void);
static void sigreap(void);
static void sigreboot(void);
-static void spawn(const Arg *);
+static void spawn(char *const []);
static Sigmap dispatchsig[] = {
{ SIGUSR1, sigpoweroff },
@@ -65,7 +61,7 @@ main(void)
if (sigfd < 0)
eprintf("sinit: signalfd:");
- spawn(&(Arg){ .v = rcinitcmd });
+ spawn(rcinitcmd);
while (1) {
FD_ZERO(&rfds);
@@ -93,7 +89,7 @@ main(void)
static void
sigpoweroff(void)
{
- spawn(&(Arg){ .v = rcpoweroffcmd });
+ spawn(rcpoweroffcmd);
}
static void
@@ -106,14 +102,13 @@ sigreap(void)
static void
sigreboot(void)
{
- spawn(&(Arg){ .v = rcrebootcmd });
+ spawn(rcrebootcmd);
}
static void
-spawn(const Arg *arg)
+spawn(char *const argv[])
{
pid_t pid;
- char *const *p = arg->v;
pid = fork();
if (pid < 0) {
@@ -121,8 +116,8 @@ spawn(const Arg *arg)
} else if (pid == 0) {
setsid();
setpgid(0, 0);
- execvp(*p, p);
- weprintf("sinit: execvp %s:", *p);
+ execvp(argv[0], argv);
+ weprintf("sinit: execvp %s:", argv[0]);
_exit(errno == ENOENT ? 127 : 126);
}
}