A job can be running or stopped (suspended).
When we are talking about foreground jobs and background jobs, are we only talking about running jobs?
Are background jobs and foreground jobs always in running state?
Does it make sense to say whether a stopped job is foreground or background?
Best Answer
Background Job : A job which is running background in the same shell. You can use bg command to see any background jobs.
Foreground job : A Job which is running in the same shell right before your eyes.
Suspended Job : Its a stopped/pause job but you can resume their running.
Let me explain with example very clealy
I have started a Job named
sleep 180
then I stopped with CTRL+Z . right now my job is in suspended mode.I see it by typing
jobs
command. Now I want to resume its running in background so I typedbg
command then it will move from suspended state to running state but in background it will run.now I typed command
fg
to bring it foreground , now job wont get stepped but it will pull from background jobs queue and push into foreground jobs queue.So yes background jobs and foreground jobs always are in running state.