Why does start_new_thread() create an extra process under Linux?

Heiko Wundram heikowu at ceosg.de
Thu Jul 29 17:42:23 CEST 2004


Am Donnerstag, 29. Juli 2004 17:31 schrieb Heiko Wundram:
> Well, first of all, what the op was seeing wasn't actually what he thought
> he was seeing.
>
> In Python there's always the main thread (which is started when python
> starts up), and other threads may be started. Thus, if you start two
> threads in your program, you'll see three processes in the process list
> (one for the main thread, two for the started threads).

Forget that, I read the first post wrong. What the op was probably seeing was 
output from an NPTL patched ps, which always shows the threads that are 
running (not only when asked for it). ps outputs one line (the first) for the 
process, all other lines are for each of the threads that are currently 
running under this process. So, the following output from ps (actually
ps ax -m on my machine) means that pickup (part of postfix) only runs one 
thread (not two processes), and xmms runs five threads.

17539 ?        -      0:00 pickup -l -t fifo -u
    - -        S      0:00 -
18338 ?        -      0:02 /usr/bin/xmms
    - -        S      0:02 -
    - -        S      0:00 -
    - -        S      0:00 -
    - -        S      0:00 -
    - -        S      0:00 -

I have an NPTL enabled glibc + kernel (without a somewhat strange patch, as 
the op seems to have), when I only type ps ax, it'll show up as:

17539 ?        S      0:00 pickup -l -t fifo -u
18338 ?        S      0:02 /usr/bin/xmms

To see whether you have an NPTL enabled glibc, type /lib/libc.so.6, and it'll 
output something like:

...
Available extensions:
...
        NPTL 0.61 by Ulrich Drepper
...

Heiko.



More information about the Python-list mailing list