Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • I added to my original question. I am confused by what you are referring to as a stopped process. Are you saying a running processes is not affected by a SIGHUP therefore nohup is not applicable on something like ./a.out & which is likely to always be running and not be affected by a SIGHUP? Commented Feb 18, 2020 at 20:50
  • 1. ps -ef | grep mysleep is not the right way to check if that process is still running: bash will optimize the last command, sleep 1000 to exec sleep 1000 -- which will run the sleep in the same process, whose name and command line will no longer include mysleep 2. I'm saying exactly the contrary of that: ./a.out & can be sent a SIGHUP if it's started from bash (or some other "advanced" shell which expands the job control implemented by the OS with its own actions). Commented Feb 18, 2020 at 21:06
  • @ron fwiw, your stopped mysleep.sh will be killed by a SIGTERM explicitly sent by bash, not by a SIGHUP, so starting it via nohup doesn't make any difference. An interactive bash also sends a SIGTERM to the stopped jobs, not just a SIGHUP + SIGCONT. Commented Feb 19, 2020 at 17:53
  • @ron I've added a section about why/when nohup may not help; another situation is when it's hup'ed before being able to ignore the sighup signal. But this is getting way off the original question and turning into a quirks and trivia collection. If the whole point of your Q was to "prove" that nohup is/was always useless and you can simply run foo & and log out and foo won't be hup'ed, THAT IS WRONG. Commented Feb 19, 2020 at 18:49