Skip to content

Instantly share code, notes, and snippets.

@rofl0r
Created August 6, 2013 21:15
Show Gist options
  • Save rofl0r/6168719 to your computer and use it in GitHub Desktop.
Save rofl0r/6168719 to your computer and use it in GitHub Desktop.

Revisions

  1. rofl0r created this gist Aug 6, 2013.
    22 changes: 22 additions & 0 deletions init.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #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 });
    }