:: Re: [DNG] Custom OS initiator. In n…
Góra strony
Delete this message
Reply to this message
Autor: Edward Bartolo
Data:  
Dla: dng
Temat: Re: [DNG] Custom OS initiator. In need of some hints...
Hi,

I downloaded and compiled Felker's minimal init but found it didn't
work. Examining the code it seems that the website had been
vandalised. According to my logic the endless loops should be at the
end rather than at the middle of the code. Furthermore, the code seems
to first block signals then it enables them back afterwards
contradicting the text.

I am quoting the website:
http://ewontfix.com/14/

The C code for Felker's minimal init is:
-------------------------------------------------------------
#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 });
}
-------------------------------------


Edward