I would like to understand the behavior of a process running with disown when a SIGHUP (or similar) from a shell logout occurs.

The process simply does the following:

  1. sleep 15 seconds
  2. print "hello";
  3. creates an empty file in /tmp

Ok, we run the process and then do a ctrl-z, bg, disown and logout.

After 15 seconds the empty file in /tmp does not exist. If I remove the second command (print), the process ends and the empty file exists, So if the process sends something to stdout without a shell attached, then receives some signal from the kernel that kills it.

The process must be in Perl, PHP or C (With Bash or Python seems that does not occur)

I know that a background execution with nohup sends the output to a file and we will not have this issue, but the question is to understand the behavior of disown command when we have executed the process with some output. (btw, disown with -h has the same result).

1 Answer 1


Your process died from a SIGTTOU.

If you like to prevent this from happening, you need to be careful not to print something to the TTY you no longer own.

  • 1
    Perhaps add commentary explaining that a background process (bg'd) trying to output to stdout will be sent SIGTTOU, which, if unhandled, will kill the process. It is defined, and expected behavior.
    – lornix
    Commented Nov 26, 2015 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .