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 Answer
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.
2 Comments
user3790147
Thank you for your reply. So the parent script will check for updates. One question though, can the parent and child process run simultaneously?
Martin Konecny
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.