[olsr-dev] debug_level=0 & standart I/O
Andreas Tønnesen
(spam-protected)
Mon Mar 28 20:06:18 CEST 2005
Nice one aaron :) It is available in Linux as well.
I'll use this call then.
- Andreas
aaron wrote:
> On Mon, 28 Mar 2005, Andreas [iso-8859-1] Tønnesen wrote:
>
> hi!
>
> in *BSD (dont know about linux) there is the nice daemon() syscall
> exactly for that. It does it the "right" way.
>
> something like
> pid=fork()
> switch(pid) {
>
> case 0: /* child */
> blabla
> stdin2=dup(0);
> stdout2=dup(1);
> stderr2=dup(2);
> close(0);
> close(1);
> close(2);
> chdir("/");
> ...
> connect to syslog if you want
> blabla
>
> default: /parent */
> blabla
> wait() or exit()
> }
>
>
> hope it is usefull
>
> a.
>
>> Hi Grégory,
>>
>> Wouldn't the right thing here be for the parent process to close the
>> handlers? Or does that not work?
>> I'll add Thomas' suggested code when I get back from vacation(tomorrow),
>> so there will be a fix for this in 0.4.9.
>>
>> - Andreas
>>
>>>
>>> Hi,
>>>
>>> I'm using PHP on a web server for making a page that start/stop
>>> olsrd.
>>> When PHP execute "olsrd -i eth0 -d 0" command (for example), it waiting
>>> for the end of command... and it never happens because while the
>>> standard I/O (stdin/stdout/stderr) are not closed, php think that the
>>> process is running...
>>>
>>> If I modified the main.c by writing "fclose(stdin); fclose(stdout);
>>> fclose(stderr)" before the setsid command (in the child code), it run
>>> ok....
>>>
>>> So, is it a good idea to close the standard I/O after the fork
>>> (for the
>>> child, the parent exit normaly) or is there an other solution ?
>>>
>>> Best regards,
>>>
>>> --
>>> Grégory Marfjan
>>>
>>>
>>>
>>> _______________________________________________
>>> olsr-dev mailing list
>>> (spam-protected)
>>> https://www.olsr.org/mailman/listinfo/olsr-dev
>>>
>>
>>
>> ---------
>> Andreas Tønnesen
>> http://www.olsr.org
>> _______________________________________________
>> olsr-dev mailing list
>> (spam-protected)
>> https://www.olsr.org/mailman/listinfo/olsr-dev
>>
>>
>
>
> ---
> Yesterday it worked.
> Today it is not working.
> Windows is like that.
> (old japanese haiku wisdom)
--
Andreas Tønnesen
http://www.olsr.org
More information about the Olsr-dev
mailing list