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.
|
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. |
Quote:
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. |
Quote:
Quote:
|
All times are GMT -5. The time now is 01:04 AM. |