nohup does not really protect program from first SIGHUP signal?

source code from /usr/src/usr.bin/nohup/nohup.c:
Code:
  (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.
 
which will clear all manual registered signal handlers.
I don't think that's true.

exec(3)
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.

signal(3)
All caught signals may be reset to their default action by a call to the execve(2) function; ignored signals remain ignored.
 
  • Thanks
Reactions: hk7
Don't know why, but this will kill vim.
on terminal 1: nohup vim
on terminal 2: killall -HUP vim
 
Don't know why, but this will kill vim.
on terminal 1: nohup vim
on terminal 2: killall -HUP vim
[FONT=Courier New]SIGHUP[/FONT] is set to be ignored by nohup, but if the process nohup executes installs a signal handler for [FONT=Courier New]SIGHUP[/FONT], it will receive this signal.
 
  • Thanks
Reactions: hk7
Back
Top