Not forking?

greg greg at cosc.canterbury.ac.nz
Fri Nov 23 20:33:34 EST 2007


Gilles Ganault wrote:
> It seems like the following doesn't actually fork,
> 
> sys.stdout = open(os.devnull, 'w') 
> if os.fork(): 
>     sys.exit(0)

What makes you think it's not forking? Chances are
it *is* forking, but something is going wrong later.
Do you get any traceback?

> try: 
>         cidnum = sys.argv[1] 
> except: 
>         print "Format: netcid.py cidnum cidname" 
>         sys.exit(1)

You realise that having directed stdout into /dev/null,
you're not going to see these messages?

What happens if you run it without any output redirection?

--
Greg



More information about the Python-list mailing list