![]() |
Re: How to disable spawnv's child process output messages
Hi Donn. Thanks for your response. Yes, in this case my parent process
is hello_moon.py that is spwaning the child process, hello_earth.py. I am simply printing a hello world from each process and do not wish to see any output messages from the child process, and i *have to* see the output from the parent process, hello_moon.py Could you please elaborate more on how i can use dup2( ) to disable the output of the child process spawned by spawnv( ) API? Regards, BB (Nushin) "Donn Cave" <donn@drizzle.com> wrote in message news:<1058938603.850678@yasure>... > Quoth nushin2@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@drizzle.com |
Re: How to disable spawnv's child process output messages
In article <db3b6d24.0307231030.7dfa1b70@posting.google.com >,
nushin2@yahoo.com (nushin) wrote: > Hi Donn. Thanks for your response. Yes, in this case my parent process > is hello_moon.py that is spwaning the child process, hello_earth.py. I > am simply printing a hello world from each process and do not wish to > see any output messages from the child process, and i *have to* see > the output from the parent process, hello_moon.py > > Could you please elaborate more on how i can use dup2( ) to disable > the output of the child process spawned by spawnv( ) API? It can't be done - as I said, spawnv can't do any kind of redirection, and that is what it would take. Donn Cave, donn@u.washington.edu ----------------------------------- > "Donn Cave" <donn@drizzle.com> wrote in message > news:<1058938603.850678@yasure>... > > Quoth nushin2@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'),('>/de > > | v/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@drizzle.com |
| All times are GMT. The time now is 09:54 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.