os.system(), HTTPServer, and finishing HTTP requests

Donn Cave donn at drizzle.com
Mon Aug 16 06:42:57 CEST 2004

Quoth "Erik Johnson" <ej <at> wellkeeper <dot> com>:
|      But if I make this same os.system() call from within my own HTTPServer,
| then the browser that is making the request is left hanging until that
| sleeping grandchild is done. It's like there is still a socket connection
| between it and my browser?!? But the grandchild is not forked from the
| server - it's an os.system() call!  It should not be inherting any file
| descriptors and such, right?

On the contrary, system() does call fork - basically,

   def system(command):
       pid = fork()
       if pid:
           return waitpid(pid, 0)[1]
           execve('/bin/sh', ['sh', '-c', command], environ)

and indeed file descriptors will be inherited.  You'll
have to explicitly close the socket.

	Donn Cave, donn at drizzle.com

More information about the Python-list mailing list