forking and avoiding zombies!
andrea.crotti.0 at gmail.com
Tue Dec 11 14:57:03 CET 2012
2012/12/11 peter <pjmakey2 at gmail.com>:
> On 12/11/2012 10:25 AM, andrea crotti wrote:
>> Ah sure that makes sense!
>> But actually why do I need to move away from the current directory of
>> the parent process?
>> In my case it's actually useful to be in the same directory, so maybe
>> I can skip that part,
>> or otherwise I need another chdir after..
> You don't need to move away from the current directory. You cant use os to
> get the current work directory
> stderrfile = '%s/error.log' % os.getcwd()
> stdoutfile = '%s/out.log' % os.getcwd()
> then call the daemon function like this.
> daemonize(stdout=stdoutfile, stderr=stderrfile)
But the nice thing now is that all the forked processes log also on
stdout/stderr, so if I launch the parent in the shell I get
DEBUG -> csim_flow.worker: Moving the log file
DEBUG -> csim_flow.area_manager: No new logs found in
where in  I have the PID of the process.
In this suggested way I should use some other files as standard output
and error, but for that I already have the logging module that logs
in the right place..
More information about the Python-list