![](https://secure.gravatar.com/avatar/2c0bde3f5628f35390c42fe505b79da4.jpg?s=120&d=mm&r=g)
Oct. 14, 2008
8:53 p.m.
OoO En cette nuit nuageuse du mercredi 15 octobre 2008, vers 00:10, "Alec Matusis" <matusis@yahoo.com> disait :
I am not sure still how to do it: When I run
twistd --python=serv.py --logfile=serv.log
anything that I put in serv.py is executed after the process has already been daemonized: even if I print or sys.stdout on the first line in serv.py file, the output never goes into stdout.
You need to save sys.stdout in serv.py and use this saved value. I have not tested it, but maybe you need to get the file descriptor instead and reopen it (fd=sys.stdout.fileno() and os.fdopen(fd, 'w')). -- Make sure input cannot violate the limits of the program. - The Elements of Programming Style (Kernighan & Plauger)