• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

nohup does not really protect program from first SIGHUP signal?


New Member

Messages: 16

source code from /usr/src/usr.bin/nohup/nohup.c:
  (void)signal(SIGHUP, SIG_IGN);

  execvp(*argv, argv);
we can see that nohup first registers SIGHUP handler to SIG_IGN, but it then execvp the program we specify. which will clear all manual registered signal handlers.



Thanks: 1,327
Messages: 1,908

which will clear all manual registered signal handlers.
I don't think that's true.

Signals set to be ignored in the calling process are set to be ignored in the new process. Signals which are set to be caught in the calling process image are set to default action in the new process image.
All caught signals may be reset to their default action by a call to the execve(2) function; ignored signals remain ignored.


Active Member

Thanks: 92
Messages: 125

Don't know why, but this will kill vim.
on terminal 1: nohup vim
on terminal 2: killall -HUP vim
SIGHUP is set to be ignored by nohup, but if the process nohup executes installs a signal handler for SIGHUP, it will receive this signal.