[python-win32] Spawning processes with os module

Paul Moore p.f.moore at gmail.com
Thu Oct 27 20:33:37 CEST 2005


On 10/27/05, Christian Junker <christianjunker at gmail.com> wrote:
> I am having difficulty spawning processes with the os.P_NOWAIT and the
> waitpid function in the os module. What I simply want to do is to
> launch another process along with immediately getting its exit status
> in a cross-platform supported way. However the exit status is actually
> shifted 8 bits left on Win32 and when manually shifting it back, I
> always get 1 as the exit status although the process has obviously
> been started successfully.

I'm a bit confused. You say you are using P_NOWAIT, and yet you want
the exit status "immediately"? os.spawnXX with P_NOWAIT returns a
process ID. This can be used in os.waitpid to get the exit status,
shifted left 8 bits, once the process does exit. But if you're just
doing

    pid = os.spawnXX(...P_NOWAIT)
    pid, status = os.waitpid(pid)
    status = status >> 8

you may as well have used P_WAIT in the first place...

Maybe if you posted some example code showing what you are trying to
do, it may make your problem clearer.

Paul.


More information about the Python-win32 mailing list