tinit.c - mkports - recipes for building multiple softwares with mk(1)
 (HTM) git clone git://z3bra.org/mkports
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       tinit.c (435B)
       ---
            1 #include <signal.h>
            2 #include <unistd.h>
            3 #include <sys/wait.h>
            4 
            5 int main () {
            6         sigset_t set;
            7         pid_t pid;
            8         int c;
            9         
           10         if (getpid () != 1) return 1;
           11         
           12         sigfillset (&set);
           13         sigprocmask (SIG_BLOCK, &set, 0);
           14         
           15         pid = fork ();
           16         if (pid < 0) return 1;
           17         if (pid > 0) for (;;) wait (&c); /* orphans */
           18         
           19         sigprocmask (SIG_UNBLOCK, &set, 0);
           20         
           21         setsid ();
           22         setpgid (0, 0);
           23         return execve ("/sbin/rc", (char * []){ "go", 0 }, (char * []){ 0 });
           24 }