:: Re: [DNG] Custom OS initiator. In n…
Top Pagina
Delete this message
Reply to this message
Auteur: Steve Litt
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Custom OS initiator. In need of some hints...
On Tue, 14 Jun 2016 08:54:12 +0200
Edward Bartolo <edbarx@???> wrote:

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


Define "didn't work." If you mean didn't compile, yeah, you need an
additional include file: Urban said it's wait.h: I don't remember. If
you mean it hung or something, make /etc/rc do nothing but run bash,
and see if you get a command prompt.


SteveT

Steve Litt
June 2016 featured book: Troubleshooting: Why Bother?
http://www.troubleshooters.com/twb