Unix Background process STOPPED abnormally
background, nohup, process, unix
Solution
There are several ways a process running in the background can be stopped. All of them involve one of these signals:
- `SIGSTOP`
- `SIGTSTP`
- `SIGTTOU`
- `SIGTTIN`
`SIGSTOP` is severe. It's unblockable, unignorable, unhandlable. It stops the process as surely as `SIGKILL` would kill it. The others can be handled by the background process to prevent stopping.
- A signal was sent by another process using `kill(2)`, or by the process to itself using `raise(3)` or `kill(2)`
- The process attempted to write to the terminal, and the terminal option `tostop` is enabled (see output of `stty -a`). This generates `SIGTTOU`.
- The process attempted to change the terminal modes with `tcsetattr(3)` or an equivalent `ioctl`. (These are the same modes shown by `stty`.) This generates `SIGTTOU` regardless of the current state of the `tostop` flag.
- The process attempted to read from the terminal. This generates `SIGTTIN`.
This list is probably very incomplete.
Problem
I executed a perl script in background using the following command ``` nohup perl myPerlSCript.pl >debug_log & ``` After few minutes I got the status as [1]+ Stopped I wasn't expecting it to stop, nor do I know what stopped it. How can I debug this and find out why it stopped? I am actually interested in knowing the unix commands to debug.