os.fork leaving processes behind

Falcolas garrickp at gmail.com
Thu Dec 27 19:36:36 EST 2007


Hi all,

This may be more of a Linux question, but it relates to how Python
forks...

Today, I implemented a pretty simple listener script using os.fork.
The script runs fine, and performs as expected, but the process table
is left with an odd entry for every fork called.

I'm running on Slackware 9, under the 2.4 kernel, Python 2.5.1.

while True:
    conn, addr  = s.accept()
    if os.fork():
        continue
    else:
        handle_connection(conn)
        sys.exit(0)

Running ps -ef results in a slew of '[ python <depreciated> ]' entries
(or something similar, I no longer have the actual output).

Will these clean themselves up if I leave the process running, and
what causes these?

Thanks in advance, G



More information about the Python-list mailing list