LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-10-2006, 01:38 PM   #1
dfego
LQ Newbie
 
Registered: Jul 2006
Location: New Rochelle, NY
Distribution: Gentoo
Posts: 18

Rep: Reputation: 0
Terminals and Background Processes


I'm not sure if this is new behavior, or just something I've never encountered, but I found it weird. I run Gentoo with Fluxbox, and have mrxvt as my terminal. When I type in a command with an & at the end,to make it a background process, it seems to work, but the process ends when I close the terminal. Should this be happening? I don't want it to happen, and there must be a way to work around it, so any help would be appreciated.
 
Old 11-10-2006, 02:01 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Yes it's normal. When you close a terminal, all child processes receive the HUP signal (Hand UP). The default behavior for most programs is to terminate when this signal is received, although it's possible for a programmer to write a program to ignore it.

There are a few ways you can prevent this.

1. prefix your command with nohup
2. run your programs in screen. This has the advantage that you can re-attach to them from another session if necessary.

I'm sure there are more too, but these two spring to mind.
 
Old 11-11-2006, 09:39 AM   #3
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
(Hand UP)
I assume that's a typo? It is of course 'Hang UP', presumably a left over from dialup serial terminal days.

You can also use 'disown <job>' after a process has started, which is the equivalent of prefixing the command with 'nohup'. disown without arguments will disown all jobs (use bg first if the're stopped, or you'll need to do a kill -CONT <pid>).

However, as matthewg42 says, the best solution is screen, since then you can reattach later.
 
Old 11-11-2006, 09:52 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by soggycornflake
I assume that's a typo? It is of course 'Hang UP', presumably a left over from dialup serial terminal days.
Oops, yes. *blush*
Quote:
Originally Posted by soggycornflake
You can also use 'disown <job>' after a process has started, which is the equivalent of prefixing the command with 'nohup'. disown without arguments will disown all jobs (use bg first if the're stopped, or you'll need to do a kill -CONT <pid>).

However, as matthewg42 says, the best solution is screen, since then you can reattach later.
Ooh, I didn't know about disown. Excellent!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get information about processes and terminals eshwar_ind Programming 1 04-27-2004 02:16 PM
background processes digit Linux - Software 3 07-27-2003 01:27 PM
processes in background zetsui Linux - General 8 06-14-2003 01:52 PM
background processes hakum Programming 1 04-08-2002 11:29 PM
Blending of Terminals into Desktop Background, How to? Kinshin Linux - General 5 03-31-2002 10:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05: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
Open Source Consulting | Domain Registration