:: Re: [DNG] tiny service state api [W…
Inizio della pagina
Delete this message
Reply to this message
Autore: Steve Litt
Data:  
To: dng
Oggetto: Re: [DNG] tiny service state api [WAS: Fwd: init system agnosticism]
On Sun, 16 Apr 2017 10:01:02 +0200
marc <marcxdv@???> wrote in response to Steve Litt:


> > And therefore I was wondering
> > why fork_parent() didn't take a function address as an argument, and
> > call that callback function's address where you have the elipses.
>
> No function pointers needed. After a fork() system call you have two
> almost identical copies of the same process. The one which sees a
> return code greater than 0 is the parent. The parent instance however
> never makes it out of the fork_parent() library call.
>
> > Yes. It makes sense. My question was where you put the code
> > represented by your elipses above.
>
> The code in the elipses runs outside the fork_parent() call. It could
> run in the main() function or elsewhere.


OK, I completely understand. It makes sense. It's pretty slick, too. I
never would have thought of it.

Being a daemontools enthusiast, I still don't see fork_parent() as an
asset in late boot. But I have a feeling it, or something similar,
could be an asset in different contexts. As a matter of fact, in my
UMENU program, I might change my backgrounding code to incorportate
that, and perhaps in doing so eliminate some sleep kludges.

Thanks,

SteveT

Steve Litt 
April 2017 featured book: Troubleshooting Techniques
     of the Successful Technologist
http://www.troubleshooters.com/techniques