Skip to content

Instantly share code, notes, and snippets.

@btbytes
Forked from rofl0r/init.c
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btbytes/637fdb7bb078da5714c5 to your computer and use it in GitHub Desktop.
Save btbytes/637fdb7bb078da5714c5 to your computer and use it in GitHub Desktop.
#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