Python daemon process

Discussion in 'Python' started by Thomas Dybdahl Ahle, Aug 26, 2006.

  1. Hi, I'm writing a program, using popen4(gnuchess),
    The problem is, that gnuchess keeps running after program exit.

    I know about the atexit module, but in java, you could make a process a
    daemon process, and it would only run as long as the real processes ran. I
    think this is a better way to stop gnuchess, as you are 100% sure, that
    it'll stop.

    Can you do this with popen?

    --
    Thomas
     
    Thomas Dybdahl Ahle, Aug 26, 2006
    #1
    1. Advertising

  2. Thomas Dybdahl Ahle

    faulkner Guest

    process = subprocess.Popen(gnuchess)
    ....
    os.kill(process.pid, signal.SIGKILL)

    Thomas Dybdahl Ahle wrote:
    > Hi, I'm writing a program, using popen4(gnuchess),
    > The problem is, that gnuchess keeps running after program exit.
    >
    > I know about the atexit module, but in java, you could make a process a
    > daemon process, and it would only run as long as the real processes ran. I
    > think this is a better way to stop gnuchess, as you are 100% sure, that
    > it'll stop.
    >
    > Can you do this with popen?
    >
    > --
    > Thomas
     
    faulkner, Aug 27, 2006
    #2
    1. Advertising

  3. 2006/8/26, Thomas Dybdahl Ahle <>:
    > Hi, I'm writing a program, using popen4(gnuchess),
    > The problem is, that gnuchess keeps running after program exit.
    >
    > I know about the atexit module, but in java, you could make a process a
    > daemon process, and it would only run as long as the real processes ran. I
    > think this is a better way to stop gnuchess, as you are 100% sure, that
    > it'll stop.
    >
    > Can you do this with popen?
    >
    > --
    > Thomas
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >

    You could send the quit (or close or wahtever) command to gnuchess
    when you want it to terminate. Supposing that gnuchess needs to do
    some stuff on exit, this is a better solution.

    PAolo

    --
    if you have a minute to spend please visit my photogrphy site:
    http://mypic.co.nr
     
    Paolo Pantaleo, Aug 27, 2006
    #3
  4. I might not have made myself very clear, since you both got me wrong.
    What I need, is not a method to terminate a process, but a way to
    terminate a process when the main process dies.

    From the atexit module info:
    Note: the functions registered via this module are not called when the
    program is killed by a signal, when a Python fatal internal error is
    detected, or when os._exit() is called.

    I belive that there is noway you can be sure to get a piece of code run,
    if the program crashes or something like that,
    therefor I ask for a way to run gnuchess as a kind of subprocess, that can
    only run when the parrentprocess is still running.

    I know this is called a daemon thread in java.

    > 2006/8/26, Thomas Dybdahl Ahle <>:
    >> Hi, I'm writing a program, using popen4(gnuchess),
    >> The problem is, that gnuchess keeps running after program exit.
    >>
    >> I know about the atexit module, but in java, you could make a process a
    >> daemon process, and it would only run as long as the real processes ran. I
    >> think this is a better way to stop gnuchess, as you are 100% sure, that
    >> it'll stop.
    >>
    >> Can you do this with popen?
    >>
    >> --
    >> Thomas
    >> --
    >> http://mail.python.org/mailman/listinfo/python-list
    >>

    > You could send the quit (or close or wahtever) command to gnuchess
    > when you want it to terminate. Supposing that gnuchess needs to do
    > some stuff on exit, this is a better solution.
    >
    > PAolo


    --
    Programmers should realize their critical importance and responsibility in a
    world gone digital. They are in many ways similar to the priests and monks of
    Europe's Dark Ages; they are the only ones with the training and insight
    to read and interpret the "scripture" of this age.
     
    Thomas Dybdahl Ahle, Aug 29, 2006
    #4
    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. Sakagami Hiroki

    Creating a daemon process in Python

    Sakagami Hiroki, Feb 21, 2007, in forum: Python
    Replies:
    9
    Views:
    979
    Nick Craig-Wood
    Feb 23, 2007
  2. Ben Finney

    Making a non-root daemon process

    Ben Finney, Mar 23, 2007, in forum: Python
    Replies:
    3
    Views:
    381
    Ben Finney
    Mar 24, 2007
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    477
    Jean-Paul Calderone
    Mar 20, 2009
  4. Floris Bruynooghe
    Replies:
    1
    Views:
    472
    Floris Bruynooghe
    Mar 24, 2009
  5. Daemon Win32::Daemon;

    , Sep 7, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    274
Loading...

Share This Page