LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-26-2008, 08:28 AM   #1
lumix
Member
 
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Rep: Reputation: 30
Job resumed in background still outputs to stdout in foreground


For heehee's I tried

Code:
me$ls -R
ctrl-z
me$bg
but the output of the dir listing resumed before my eyes. I thought bg meant resume in background, which meant...in the background. Which, I guess I thought meant resume it but disconnect stdio from it and connect it to a new command prompt. Of course, I'm not entirely sure what I mean by "a new command prompt", exactly.

What exactly is happening with these commands, then?
 
Old 11-26-2008, 09:23 AM   #2
linest
LQ Newbie
 
Registered: Sep 2008
Posts: 23

Rep: Reputation: 1
Running a process in the background allows you to continue working but it doesn't necessarily disconnect stdin, stdout or stderr.

Disconnection from stdin is done via the "nohup" command. You can dispose of stdin and stderr with something like "ls -al > /dev/null 2>&1".
 
Old 11-26-2008, 10:23 AM   #3
lumix
Member
 
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Original Poster
Rep: Reputation: 30
I see. Seems like that would kind of detract from the usefulness of bg, though. Why put X in the "background" if in fact its presence is still much in the fore? If I want something to run somewhere while still allowing me to run new stuff, then I'd think it would be a nuisance, if not impossible, to do so since the first task keeps obstructing the i/o of the second.

Not trying to be argumentative, really. Just trying to understand the utility of the function is all. In any case, thanks for the reply.
 
Old 11-28-2008, 08:05 PM   #4
linest
LQ Newbie
 
Registered: Sep 2008
Posts: 23

Rep: Reputation: 1
Quote:
Originally Posted by lumix View Post
I see. Seems like that would kind of detract from the usefulness of bg, though. Why put X in the "background" if in fact its presence is still much in the fore? If I want something to run somewhere while still allowing me to run new stuff, then I'd think it would be a nuisance, if not impossible, to do so since the first task keeps obstructing the i/o of the second.

Not trying to be argumentative, really. Just trying to understand the utility of the function is all. In any case, thanks for the reply.
I don't disagree.

If the program you're putting in the background is well behaved enough it's OK, but many are not. Try getting "top" to run in the background sometime. It just doesn't know what to do there.

The real benefit of "nohup XYZ > /dev/null &" is in automated batch processes that will execute via cron or init without the benefit of a keyboard or screen. It allows the program to open stdin/out and continue. For interactive use, the existence of multiple virtual terms or an xterms generally makes "&" the third best choice.
 
  


Reply



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
tty background/foreground color neo77777 Linux - General 11 11-25-2014 08:59 AM
background process popping up in foreground noir911 Linux - General 1 12-14-2007 11:53 PM
Foreground and Background program switching isolvesystems Linux - Newbie 2 10-03-2007 09:30 AM
How to bring a background diamon to foreground lieuquocdat Linux - Software 8 07-20-2006 06:53 AM
Background and Foreground Datamike Linux - Software 2 01-20-2006 04:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:37 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration