Timeline for Why use "nohup &" rather than "exec &"
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 31, 2018 at 10:01 | vote | accept | loxaxs | ||
| Jul 31, 2018 at 10:03 | |||||
| Feb 1, 2017 at 21:06 | comment | added | Dan Pritts |
I mean it doesn't get exec'd in the sense that you would normally think of (replacing the current running shell) - it just gets run as a background process. I guess it probably is the same as (exec smth) &. But I wouldn't expect it to be the same - I would expect it to be a syntax error, how can you exec a process (replacing yourself) and then background the exec'd process? You're not there to do it anymore.
|
|
| Feb 1, 2017 at 19:11 | comment | added | phk |
@DanPritts What do you mean with it does not happen? A background subprocess gets started and then replaced, so exec smth & is the same as (exec smth) &, isn't that what's happening?
|
|
| Jul 29, 2016 at 21:53 | comment | added | Dan Pritts |
This answer appears to be correct. As other answers above say, normally exec replaces the running process, but that doesn't seem to happen when you use & to background the exec'd command. Neither in bash nor zsh.
|
|
| Jul 20, 2016 at 4:30 | history | answered | Ani Menon | CC BY-SA 3.0 |