0

Mostly, if I closed the current terminal, the sub_process are also closed. Of course, if I use suspend the process and use `bg JobID wakeup it, the process is divided with the terminal and run in background. So what the relationship between the current terminal and the process that is triggered by the terminal. Are they father-son or brothers? What's more, how could I use the command line to trigger a process which needn't attach to the terminal.

2 Answers 2

2

You are right about the father-son behavior. Processes that you are starting from the command line are getting their signals from the terminal instance. Once you close the terminal it will send a HUP (hangup) signal to the depending processes.

This is very useful when you have only one terminal so that once you logout it will notify all processes that the user logged out and they should terminate their activity. However, in your case you want to process(es) to ignore this signal and continue their work even after the terminal has been closed. For that we have a special command called nohup that you should prefix with your regular command (e.g. nohup gedit).

You may also ask where does the output that went to console goes after a terminal is closed. Well, a file in your home directory called nohup.out is being created and all output from processes will be redirected to it.

Please notice, the nohup does not open the process in background so you will still need to add & postfix if you want it (e.g. nohup gedit &).

1
  • 1
    Also note, that once a job is running in the background (either through bg or an appended ampersand), you can use disown to prevent the shell from sending SIGHUP when terminating. May 3, 2012 at 12:00
0

You can use the nohup command to prevent a child process to be exited when you close the terminal. For instance nohup gcalctool. Nohup is for "No hang-up".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .