I was running an application in the foreground, and put it in the background by hitting CTRL+Z (and stopped).
To get it back running, I ran the command bg %1
(which is its JOBSPEC).
I thought why not trying to get it running back with kill -CONT <PID>
. So, I ran jobs -l
to get its PID, and used this pid with kill with CONT signal.
However, the program didn't go live again! jobs -l
after trying kill with CONT reports that it is running, but it is not (as it is grayed out).
I looked at the applications PID using the command ps
and found two of the same command with different PIDs (and status Tl
).
I then looked at the same thing using pstree
and found they are all under a parent process. The parent process is different from the one listed by jobs -l
as it seems the one I put in the background initiated another program. The other program seems created children processes.
What I noticed is summarized as:
Using
kill
to send CONT to the parent process gets the program running.The parent process PID is different from the one reported by
jobs -l
. In other words, the process I should have sent CONT signal to is different from the one I find usingjobs -l
.Sending CONT to a parent process doesn't apply the same signal on the children.
Using the command
bg
to return a process to running, sends CONT signal to the parent all its children.
Are my conclusions correct? If so, then this means using the command bg
would save time of sending CONT to every related process.is this correct?
EDIT The main application I called from the command line and which I put in the background is git difftool
. The other application that I am talking about that it created new children itself is meld
which I setup to be used as the diffing tool in git.