Python start subprocess in background7/29/2023 ![]() When you use logout, this isn't a SIGHUP, and so the shell won't send a SIGHUP to any of its children.Īdditionally you must make sure that your program doesn't write to the terminal through STDOUT or STDERR, as both of those will no longer exist once the terminal exits. Use logout (or Ctrl+ d) instead of closing the terminal window.And unless it installs a signal handler for SIGHUP, it keeps the ignore action anyway. Because it forked, the program being launched is not a child of the shell, and the shell doesn't know about it. Basically it ignores the SIGHUP signal, and then forks & executes your program which inherits the setting, and then exits. This accomplishes the same thing, but by using an intermediate process. Prefix your command with nohup ( nohup $python program.py &).This will make the shell forget about it. Use the disown command after backgrounding your process.Disassociate the backgrounded program from your shell.So your remote shell then sends a SIGHUP to all its processes, your backgrounded program. The ssh then forwards the SIGHUP to what it's running, the remote shell. Your shell then forwards that SIGHUP to everything it's running. When you close a terminal window, the terminal emulator sends a SIGHUP to the process it is running, your shell. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |