LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 04-15-2007, 04:18 AM   #1
une
Member
 
Registered: May 2004
Location: Australia
Distribution: Mandrake 10, Puppy Linux 2.13
Posts: 201

Rep: Reputation: 30
Stopped jobs


I notice that sometimes when I execute the "exit" command to close a terminal I get the message;
There are stopped jobs.
What does this mean?
If I immediately execute "exit" again, I do not get this message and the terminal closes. What is going on here?
 
Old 04-15-2007, 05:07 AM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Stopped jobs mean that you have started some processes (programs usually) that are in "stopped" state, and if you try to issue exit your shell (bash commonly) notices you that there are processes that haven't ended (and if you exit, they get killed because they're child processes of your login). The second exit works because after the first one you're already informed, and issuing second exit tells your shell you know the processes get killed and don't care about it, but want to exit. If it prevented you from exiting, and instead always prompted you, you might get into small trouble if the processes were persistent

To see what processes there are (stopped, running or whatever) you usually use
Code:
jobs
to get a list of them. Then, possibly depending on the shell you use (I use bash almost all the time) you deal with the processes if you like to. To kill a process by it's process id (pid):
Code:
kill pidnum
where pidnum is the id number of the process (get from ps for example). However if you use jobs to get the list, you may often refer to the processes using percent-number:
Code:
kill %1
the above would try to kill the program that was the first-started in the list (2 for second etc.); the numbers should be told when using jobs command. If the process is persistent, you may try to kill it instantly (without allowing the process time to exit cleanly):
Code:
kill -9 %1
and so on. Read
Code:
man kill
man jobs
man ps
man fg
man bg
for more information (I'm not sure if all those have manpages, but hope so).

For your information, you may start a process in the background like this:
Code:
/usr/bin/xterm &
meaning that it's not visible in your terminal (&-mark) but it's running in the background. After this if you stop it using CTRL-Z, or if the process needs to get more information (i.e. it asks you "Password: " or something, so it cannot continue it's run before you've interacted with it -- for example), it's stopped. That means the process is still alive, and possibly in the background, but not running at the moment. To get a process from the background to foreground (so you can see it, and maybe continue it's run) you use -- for example, like above --
Code:
fg %1
and refer to the second started program with %2 etc.
 
Old 04-15-2007, 05:28 PM   #3
une
Member
 
Registered: May 2004
Location: Australia
Distribution: Mandrake 10, Puppy Linux 2.13
Posts: 201

Original Poster
Rep: Reputation: 30
Thanks for such a detailed response. So it seems a job and a process are the same thing (variability of computer terminology often gets me confused). Is killing a process the only way of stopping it? For example I think I have received the "stopped jobs" warning after using Ctrl-z to stop a program such as "less". Is there a better way to exit a process so as to avoid the "stopped jobs" warning, or will the warning always appear? I am thinking that by receiving the "stopped jobs" warning I am not interacting with the OS in the most correct and controlled way possible.
 
Old 04-15-2007, 05:40 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,059

Rep: Reputation: 295Reputation: 295Reputation: 295
If you want to kill a process rather than suspend it, you can hit CTRL+C in the shell. CTRL+Z is to suspend a program that you wish to resume (or run in the background). CTRL+C kills the program (it does the same thing as using kill with no arguments, i.e. sends the process SIGTERM).
 
Old 04-15-2007, 06:58 PM   #5
une
Member
 
Registered: May 2004
Location: Australia
Distribution: Mandrake 10, Puppy Linux 2.13
Posts: 201

Original Poster
Rep: Reputation: 30
Thanks. I will check, but sometimes I think Ctrl-c has no effect. I will test this.
If Ctrl-z suspends a process, how do you resume it if it has been suspended in this way?
 
Old 04-16-2007, 07:03 AM   #6
mjolnir
Member
 
Registered: Apr 2003
Posts: 661

Rep: Reputation: 68
Glad you asked this question as I wondered about "stopped jobs" but was to lazy to search for an answer. It turns out there is a "man bg", I just tried it out by starting a process(dpkg --get-selections | less), hit(ctrl+z) after the first page of output, and typed "bg" at the prompt. I then started elinks, browsed a while, quit, and typed "fg" at the prompt. Up popped less at the point where I stopped it. This works for the last process stopped otherwise you have to identify the process.
 
Old 04-16-2007, 09:19 AM   #7
une
Member
 
Registered: May 2004
Location: Australia
Distribution: Mandrake 10, Puppy Linux 2.13
Posts: 201

Original Poster
Rep: Reputation: 30
Thanks. Sounds good, I will try it out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show the list of stopped and background jobs fakhrul Linux - General 6 01-09-2012 09:58 AM
Printer? How resume Jobs if Printer Stopped: jobs stopped? Reluctant Linux - General 0 06-03-2006 01:36 PM
Stopped jobs AndeAnderson Debian 4 03-01-2005 12:15 PM
"There are stopped jobs."+Vmailmgr DannoNZ Linux - Newbie 6 10-02-2004 05:12 PM
vim ("there are stopped jobs" 77hh77 Linux - Newbie 1 03-25-2003 12:24 PM


All times are GMT -5. The time now is 11:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration