-
-
Save karnauskas/c2ee29b1931d3cdf9849d1df1d0dfec5 to your computer and use it in GitHub Desktop.
minimal init daemon by rich felker, author of musl libc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _XOPEN_SOURCE 700 | |
#include <signal.h> | |
#include <unistd.h> | |
int main() | |
{ | |
sigset_t set; | |
int status; | |
if (getpid() != 1) return 1; | |
sigfillset(&set); | |
sigprocmask(SIG_BLOCK, &set, 0); | |
if (fork()) for (;;) wait(&status); | |
sigprocmask(SIG_UNBLOCK, &set, 0); | |
setsid(); | |
setpgid(0, 0); | |
return execve("/etc/rc", (char *[]){ "rc", 0 }, (char *[]){ 0 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment