Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

Recursion

(56,582 posts)
4. The real problem is there should not be a "wandering init proc"
Fri May 9, 2014, 12:53 AM
May 2014

Take OpenBSD or Slackware's init: beyond some compiler macros and other conveniences, it boils down to this:


#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 });
}


PID 1 shouldn't be doing anything else. I mean, seriously, did anybody look at their init program and think, "man, what this really needs is a log colorizer and QR code validator..."

Recommendations

0 members have recommended this reply (displayed in chronological order):

Latest Discussions»Culture Forums»Open Source and Free Software»Linus Torvalds suspends k...»Reply #4