Timeline for Why use "nohup &" rather than "exec &"
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 27, 2022 at 18:19 | comment | added | Gilles 'SO- stop being evil' |
@shadowtalker This is about the terminal, not the shell. If the program tries to read from its standard input and fails because the terminal has gone away, it might decide to terminate prematurely. nohup only prevents the automatic SIGHUP, not a decision by the program. Some implementations of nohup actually redirect stdin to /dev/null, but not all.
|
|
| Oct 27, 2022 at 15:28 | comment | added | shadowtalker |
What's the purpose of the </dev/null input redirection? Would stdin otherwise somehow be "left hanging" when the shell closes?
|
|
| Jul 31, 2018 at 10:03 | vote | accept | loxaxs | ||
| Jan 17, 2018 at 8:01 | comment | added | David | Give a man a fish and you feed him for a day. Give a man a bicycle and he can ride it to the supermarket and buy fish for a lifetime. | |
| Jul 31, 2017 at 0:42 | comment | added | Gilles 'SO- stop being evil' |
@GypsyCosmonaut After you run exec firefox, the shell is no longer running: it has been replaced by firefox. You can think of exec as combining exiting a program and starting a new one, but keeping the same process ID. The terminal keeps running because nothing told it to stop. When you later exit Firefox, the firefox process terminates. The terminal notices that its child process has exited and so it exits in turn.
|
|
| Jul 29, 2017 at 18:38 | comment | added | GypsyCosmonaut |
By testing I saw that when I ran exec firefox and then closed firefox, it also closed my shell. I understood what nohup does but I don't understand what you mean when you say exec replaces the shell with the <program> ?
|
|
| Jan 3, 2017 at 8:43 | comment | added | Gilles 'SO- stop being evil' | @THISUSERNEEDSHELP But a bicycle is better food, surely? | |
| Jan 3, 2017 at 1:54 | comment | added | THIS USER NEEDS HELP | I beg to differ. Fish is obviously a superior method of transportation if it can be implemented. | |
| Nov 4, 2016 at 16:26 | comment | added | Chris Jaynes | a bicycle > a fish | |
| Oct 29, 2016 at 11:43 | vote | accept | loxaxs | ||
| Jul 31, 2018 at 10:01 | |||||
| Oct 29, 2016 at 11:36 | vote | accept | loxaxs | ||
| Oct 29, 2016 at 11:43 | |||||
| Jun 19, 2014 at 1:21 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |