LinuxQuestions.org
Review your favorite Linux distribution.
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 07-07-2009, 05:42 PM   #1
SPearson
LQ Newbie
 
Registered: Jul 2009
Location: Mukilteo, WA
Distribution: Ubuntu
Posts: 3

Rep: Reputation: 0
Running a program from the shell followed by '&'


If I do, for example,

Code:
emacs &
emacs will load and the terminal will 'return,' allowing more commands to be input. If I close the terminal, however, emacs also closes. I thought '&' prevented this. Why does emacs still close? Thx for any replies
 
Old 07-07-2009, 05:44 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi,

and welcome to LQ!

Because that terminal is still its parent. Try a "nohup emacs &" and
see how that goes.


Cheers,
Tink
 
Old 07-07-2009, 05:57 PM   #3
SPearson
LQ Newbie
 
Registered: Jul 2009
Location: Mukilteo, WA
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
I tried this, but the terminal does not seem to "return," so when I close it, emacs also closes.

Code:
nohup: ignoring input and appending output to `nohup.out'
[1] 14423
 
Old 07-07-2009, 06:26 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Odd ...


What Linux distro are you using, which DE/WM, which terminal emulator?



Cheers,
Tink
 
Old 07-07-2009, 07:01 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
How do you expect to operate a text editor that isn't attached to the terminal? The program itself is probably exiting.
nohup vim &
will bail before you even try terminating the parent.
 
Old 07-07-2009, 07:04 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
How do you expect to operate a text editor that isn't attached to the terminal? The program itself is probably exiting.
emacs (in most distros, anyway, if invoked w/o the -nw option) is actually
an X application ....



Cheers,
Tink
 
Old 07-07-2009, 07:04 PM   #7
SPearson
LQ Newbie
 
Registered: Jul 2009
Location: Mukilteo, WA
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
I am using Ubuntu 9.0.4 32-bit Desktop Edition. The desktop environment is GNOME 2.26.1; the terminal emulator is GNOME Terminal 2.26.0. I am running the OS in a virtual machine.
 
Old 07-07-2009, 10:01 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
Quit putting the & at the end then.

"If a command is terminated by the control operator &, the shell executes the command asynchronously in a subshell. This is known as executing the command in the background. The shell does not wait for the command to finish, and the return status is 0 (true). When job control is not active (see Job Control), the standard input for asynchronous commands, in the absence of any explicit redirections, is redirected from /dev/null. "


Hope I'm correct on that.

Last edited by jefro; 07-07-2009 at 10:11 PM.
 
Old 07-07-2009, 10:31 PM   #9
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
Quote:
Originally Posted by jschiwal View Post
How do you expect to operate a text editor that isn't attached to the terminal?
There's a difference, however, between being attached to a terminal and see that terminal in front of yourself.
As a funny example, type

screen emacs &

in an xterm and then close this xterm window. ps aux will however reveal that the emacs process is attached to a terminal, but where is it?
 
  


Reply

Tags
terminal


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
running a shell script which invokes another shell program!!! raghu123 Programming 1 08-04-2008 10:10 AM
running a C program from shell script jkeertir Linux - Newbie 3 05-19-2008 06:05 AM
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 02:35 AM
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 10:14 PM
running a program from shell script Suinatsa Programming 10 04-14-2005 12:25 PM


All times are GMT -5. The time now is 04:48 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration