process wrapper?

Donn Cave donn at
Mon Mar 29 22:04:58 CEST 2004

In article <QZ2dnbPGnqPo6_Xd38DK-g at>,
 "Steve @ Waypath" <steve at> wrote:

> Thanks for the reply. I haven't yet implemented a working spawnv call, so
> I'm not confident my tests are valid. Here's a sample:
> ##########
> File:
> ------------
> import os, time
> if __name__=='__main__':
>  os.spawnv(os.P_NOWAIT,'python',[''])

OK, that can be fixed.

When the documentation says "path" for some functions, and
"file" for others (e.g., spawnvp), the distinction is that
"path" includes the directory specification, either absolute
or relative to the current working directory.  spawnv wants
a path, so the above doesn't work unless "python" is a file
in your current working directory.  To resolve this problem,
I would just write in the absolute path, or you may use spawnvp

But don't give it python's path.  Instead, at least consider
invoking the Python program file directly - put its path there
as the 2nd parameter, not python's.  Then your argument list
(the 3rd parameter) will be correct as written.  If you invoke
python itself, then you'll need to make the second
argument, directing python to interpret that file.  If you
decide to do as I suggest, will have to be executable
(chmod 755) and start with a line like "#!/usr/bin/python", as
appropriate for your system.  From there on, your
program no longer needs to know how is actually

> ###########
> While test 1 is running, a ps (in another shell):
> # ps x | grep python
> 11726 pts/1  S   0:00  python
> 11727 pts/1  Z   0:00 [python <defunct>]
> 11729 pts/2  S   0:00 grep python
> ###########
> I see this defunct thing with every spawnv test I try. The defunct process
> goes away when the calling process (, in this case) finishes. Where
> am I going wrong here?

It's a zombie!  UNIX leaves a dead process in the table as
long as its parent might come back and ask for the status.
It goes either when the parent gets its status with a wait
function (like waitpid()), or when the parent exits.

   Donn Cave, donn at

More information about the Python-list mailing list