2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <sys/types.h>
17 #include <sys/mount.h>
26 static struct uloop_process preinit
;
28 static void spawn_procd(struct uloop_process
*proc
, int ret
)
30 char *wdt_fd
= watchdog_fd();
31 char *argv
[] = { "/sbin/procd", NULL
};
33 unsetenv("INITRAMFS");
35 DEBUG(1, "Exec to real procd now\n");
37 setenv("WDTFD", wdt_fd
, 1);
38 execvp(argv
[0], argv
);
41 void procd_preinit(void)
43 char *argv
[] = { "/bin/sh", "/etc/preinit", NULL
};
47 setenv("PREINIT", "1", 1);
48 preinit
.cb
= spawn_procd
;
51 execvp(argv
[0], argv
);
52 ERROR("Failed to start preinit\n");
56 if (preinit
.pid
<= 0) {
57 ERROR("Failed to start new preinit instance\n");
61 uloop_process_add(&preinit
);
62 DEBUG(2, "Launched preinit instance, pid=%d\n", (int) preinit
.pid
);