Re: How to disable spawnv's child process output messages

Discussion in 'Python' started by nushin, Jul 23, 2003.

  1. nushin

    nushin Guest

    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" <> wrote in message news:<1058938603.850678@yasure>...
    > Quoth (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,
    nushin, Jul 23, 2003
    #1
    1. Advertising

  2. nushin

    Donn Cave Guest

    In article <>,
    (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 Cave" <> wrote in message
    > news:<1058938603.850678@yasure>...
    > > Quoth (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 Cave, Jul 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grant Edwards
    Replies:
    2
    Views:
    637
    Donn Cave
    Jul 24, 2003
  2. nushin
    Replies:
    0
    Views:
    334
    nushin
    Jul 29, 2003
  3. nushin
    Replies:
    3
    Views:
    6,815
    nushin
    Aug 7, 2003
  4. Gauri
    Replies:
    3
    Views:
    170
  5. Gauri
    Replies:
    4
    Views:
    177
    -berlin.de
    Feb 28, 2007
Loading...

Share This Page