How to disable spawnv's child process output messages
Donn Cave
donn at drizzle.com
Wed Jul 23 01:36:45 EDT 2003
Quoth nushin2 at yahoo.com (nushin):
| I have a program called hello_earth.py that is spawned by
| hello_moon.py, using spawnv( ) API as:
|
| os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python','hello_earth.py'),('>/dev/null
| &'))
|
| I do not wish to see any output messages from the hello_earth.py when
| it is launched by its parent process and i do wish to see *only* the
| output messages from the parent process in the shell. Is Python
| capable to so such a thing?
What is the parent process in the shell? You mean the one that calls
spawnv()? If so - yes, Python can do that. But not so easily. You
can look at how spawnv is implemented (it's in Python), and read up
on the dup2 function (man 2 dup2) to see what's needed. spawnv can't
do any kind of redirection. I think I posted an example here a couple
weeks ago.
Or you can use the shell, more or less the way you were going but you
never invoked it -
os.spawnv(os.P_NOWAIT, '/bin/sh', ['sh', '-c', 'python hello_earth.py > /dev/null'])
which is really about the same as
os.system('python hello_earth.py > /dev/null &')
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list