![]() Here's the solution I found that actually works ' creationflags=subprocess.DETACHED_PROCESS': import subprocess I encountered a similar issue while working with qnx devices and wanted a sub-process that runs independently of the main process and even runs after the main process terminates. communicate() in the parent would return when its immediate child exits. Sometimes something in between could be enough e.g., it is enough to redirect the inherited stdout in a grandchild so that. To disassociate the child process completely, you should make it a daemon. check_output or the child may die prematurely on Ctrl-C (SIGINT signal is sent to the foreground process group) or if the terminal session is closed (SIGHUP). On the other hand, the child process may inherit various properties/resources from the parent such as open file descriptors, the process group, its control terminal, some signal configuration, etc-it may lead to preventing ancestors processes to exit e.g., Python subprocess. ![]() In that sense, all subprocesses are background processes. wait() method explicitly if you want to wait for the child process. Popen() starts a child process-it does not wait for it to exit. How to verify that via another terminal window: $ ps aux | grep python > p = subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print('finished') Here is verified example for Python REPL: > import subprocess ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |