Sujet : Re: nohup Versus setsid
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shellDate : 13. Sep 2024, 23:32:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vc2eiq$12592$11@dont-email.me>
References : 1 2
User-Agent : Pan/0.160 (Toresk; )
On Fri, 13 Sep 2024 19:00:45 +0200, Helmut Waitzmann wrote:
"nohup" makes the invoked command immune to the HUP signal but lets it
remain in its terminal session, i. e. the command to be run will not
lose its controlling terminal. Thus the other job control signals like
TSTP, INT, and QUIT sent by the terminal driver to the command may have
their effects.
See, I always thought the point of that was to allow the job to continue
after you log off. After all, what was the original meaning of the “HUP”
(hangup) signal? It meant the modem had disconnected -- the phone line had
hung up.
If, on the other hand, you use "setsid", the command to be run will not
be made immune to any of the job control signals, i. e. any job control
signal sent to the command to be run by means of the kill(2) system
call will have its effect.
That’s because setsid starts an entirely new session group, not connected
to your terminal at all. So it is not vulnerable to any of those remaining
signals from your terminal, that nohup does not block.
That’s another reason why I think setsid is better than nohup.