:: Re: [DNG] tiny service state api [W…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: marc
Fecha:  
A: dng
Asunto: Re: [DNG] tiny service state api [WAS: Fwd: init system agnosticism]
Hello

> Wait. Are you saying that the way fork_parent() is used is to modify
> the source code of fork_parent() itself?


No - you just call it, like daemon(). Then later, outside fork_parent()
you call close().

> I was under the impression that fork-parent() was a library
> call that you made to properly background your source code, which
> exists outside of function fork_parent().


That is the correct impression.

> 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.

> Is fork_parent() a template (in the general
> sense, not the C++ sense) that you modify,


No, not a template.

> or is it a tool you use, as
> is, to background code you put in a separate function?


It is a library call.

regards

marc