Re: end child process when parent dies (on Unix)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lawrence D'Oliveiro

    Re: end child process when parent dies (on Unix)

    Дамјан ГеоргиеР²ÑÐºÐ¸ wrote:
    I'm starting a Unix tool with subprocess.Pope n() from a python script
    and I want the child to be killed when the parent (my script) ends for
    whatever reason *including* if it gets killed by SIGKILL.
    A Linux-specific solution is prctl(2).
  • =?UTF-8?B?0JTQsNC80ZjQsNC9INCT0LXQvtGA0LPQuNC10LLR

    #2
    Re: end child process when parent dies (on Unix)

    >I'm starting a Unix tool with subprocess.Pope n() from a python script
    >and I want the child to be killed when the parent (my script) ends
    >for whatever reason *including* if it gets killed by SIGKILL.
    >
    A Linux-specific solution is prctl(2).
    I've tried this in a test C program... exactly what I need. Now if I
    could slip this between the fork and exec in subprocess.Pope n()


    --
    дамјан ( http://softver.org.mk/damjan/ )

    In theory, there is no difference between theory and practice.
    But, in practice, there is.

    Comment

    • Lawrence D'Oliveiro

      #3
      Re: end child process when parent dies (on Unix)

      Дамјан ГеоргиеР²ÑÐºÐ¸ wrote:
      >>I'm starting a Unix tool with subprocess.Pope n() from a python script
      >>and I want the child to be killed when the parent (my script) ends
      >>for whatever reason *including* if it gets killed by SIGKILL.
      >>
      >A Linux-specific solution is prctl(2).
      >
      I've tried this in a test C program... exactly what I need. Now if I
      could slip this between the fork and exec in subprocess.Pope n()
      An obvious way, if you're trying to hack something without the source, is to substitute your own executable which does the prctl before execing the real executable.

      Comment

      • Miles

        #4
        Re: end child process when parent dies (on Unix)

        On Mon, Nov 17, 2008 at 2:51 AM, Дамјан ГеоргиеР²ÑÐºÐ¸ wrote:
        >>I'm starting a Unix tool with subprocess.Pope n() from a python script
        >>and I want the child to be killed when the parent (my script) ends
        >>for whatever reason *including* if it gets killed by SIGKILL.
        >>
        >A Linux-specific solution is prctl(2).
        >
        I've tried this in a test C program... exactly what I need. Now if I
        could slip this between the fork and exec in subprocess.Pope n()
        preexec_fn, perhaps?

        Source code: Lib/subprocess.py The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace seve...


        -Miles

        Comment

        Working...