Sujet : Re: nohup Versus setsid
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shellDate : 12. Sep 2024, 12:37:58
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vbujqm$1t0jr$1@news.xmission.com>
References : 1
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
vbtqcd$2sce$1@dont-email.me>,
Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
It has long seemed to me that nohup(1) was an old, hacky way of doing
what can be done more elegantly using setsid(1). Compare the docs for
yourself <https://manpages.debian.org/1/nohup.1.en.html> vs
<https://manpages.debian.org/1/setsid.1.en.html>, and tell me why we
still need nohup when we have setsid?
First, I do get what you're saying - and I've both A) Used setsid(2) a lot
over the years so am familiar with it and B) Always thought that nohup(1)
was old and crusty. I cringe whenever I hear people recommend it in help
groups nowadays.
That said, it is kind of apples-to-oranges comparison. nohup(1) is more of
a command, while setsid(1) is really just a thin wrapper around the system
call. According to the man page, nohup(1) does a lot of things, including
setting up logging and so on; there is no underlying system call. OTOH, to
understand setsid(1), you really have to understand the underlying system
call - and that system call is not simple. It (setsid(2)) is kind of a
"bigger/better" version of setpgrp() and it has some interesting
restrictions on its use. In a way, it could be said that both sessions and
process groups were only implemented to support shell job control, and this
is kind of a funny thing, since shell job control is now sort of thought of
as an anachronism (I still use it, but I seem to be in some kind of minority).
So, despite what I said 2 paragraphs ago, nohup(1) may be better as a
recommendation to the newbie.
Just out of curiosity, what is the underlying-context/reason-for-posting of
this thread? And, why in a shell group? Isn't it really a
comp.unix.programmer type question?
-- Just for a change of pace, this sig is *not* an obscure reference tocomp.lang.c...