[sr-dev] Patches to get proper status code in daemonize mode

marius zbihlei marius.zbihlei at 1and1.ro
Mon Apr 19 16:44:32 CEST 2010


Iñaki Baz Castillo wrote:
> 2010/4/19 marius zbihlei <marius.zbihlei at 1and1.ro>:
>
>   
>> Indeed, main process is the process after the fork, and this is the
>> process that writes to signal the parent. I see two possible pitfalls:
>>     
>
>   
>> 1. If the main process blocks, this will block the parent process also
>>     
>
> This could be improved using select() with a timeout, right?
>
>
>   
Hello
I have attached to this email a new main.c.patch containing the select 
changes (timeout is 30 seconds, hard coded :) )
I have taken the liberty to also format your initial patch.
>> 2. If the main process returns without writing the bytes, and there are
>> still child processes left(tcp or udp worker children etc), then they will still
>> have the writing part of the socket open (forked from the main process)and again
>> the parent (master) process will keep blocking (didn't discovered a case where it might happen).
>>     
>
> Then the workers should immediately close the pipe output fd after
> being created, right?
>
>   
>
>> Good question.. We can kill all children from the main proces, but I am not
>> sure that from the masetr process we can do this..
>>     
>
> But if we just kill the main process from the parent process, then all
> the workers and rest of children would be killed, right?
> The problem would be if the main process gets "blocked" for some
> reason, but I think that is a terrible case I've never seen.
>
>
>   
I have not yet provide with a solution for this case. If the select 
timeout is finished, then the main process will try to write to a pipe 
that the other end stop reading, receive EPIPE and kill all its 
children. This is the case in witch the main process reaches the write 
part, if it's blocked somewhere else... well this must be taken care of.
>
> Regards.
>
>
>   

Cheers
Marius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c.patch
Type: text/x-diff
Size: 5435 bytes
Desc: not available
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20100419/68b537ea/attachment-0001.patch>


More information about the sr-dev mailing list