• 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?

hk7

New Member


Messages: 15

#1
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.
 

tobik@

Daemon
Developer

Thanks: 1,179
Messages: 1,770

#2
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.
 

hk7

New Member


Messages: 15

#3
Don't know why, but this will kill vim.
on terminal 1: nohup vim
on terminal 2: killall -HUP vim
 

mrclksr

Active Member

Thanks: 97
Messages: 117

#4
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.