0

Im working on two scripts. One script is perpetually running. When it senses an update to itself, it will run the second script as a subprocess. The second script should kill the first script, implement the changes and run the updated script. However, I cant find a way to kill the first script. How does the child process kill its parent?

1
  • Not sure it's a great design. Here is one way to do so in general (Linux), and it's easily translated to Python. Commented May 21, 2015 at 5:09

1 Answer 1

1

You are doing this backwards, and shouldn't be using the child process to kill the parent process.

Instead, you will want a parent process of your "perpetually running" script (which will now be the subprocess). When an update is detected, the subprocess kills itself, and requests that the parent implement your changes. The parent will then restart the subprocess.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your reply. So the parent script will check for updates. One question though, can the parent and child process run simultaneously?
Yes, it is not a problem to run them simultaneously at all. A subprocess is a separate process meaning it can run in parallel to the parent process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.