Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You will be awarded some great honor.


comp / comp.unix.shell / Re: nohup Versus setsid

SubjectAuthor
* nohup Versus setsidLawrence D'Oliveiro
+* Re: nohup Versus setsidKenny McCormack
|`* Re: nohup Versus setsidJanis Papanagnou
| `* Re: nohup Versus setsidLawrence D'Oliveiro
|  `* Re: nohup Versus setsidvallor
|   +* Re: nohup Versus setsidLawrence D'Oliveiro
|   |`* Re: nohup Versus setsidJanis Papanagnou
|   | `* Re: nohup Versus setsidHelmut Waitzmann
|   |  `- Re: nohup Versus setsidJanis Papanagnou
|   `- Re: nohup Versus setsidKaz Kylheku
+- Re: nohup Versus setsidKaz Kylheku
`* Re: nohup Versus setsidHelmut Waitzmann
 +- Re: nohup Versus setsidKaz Kylheku
 `- Re: nohup Versus setsidLawrence D'Oliveiro

1
Subject: nohup Versus setsid
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 04:23 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: nohup Versus setsid
Date: Thu, 12 Sep 2024 04:23:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <vbtqcd$2sce$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 12 Sep 2024 06:23:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c5647ce48d163d1fa81e213bd6f20c9e";
logging-data="94606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kR2e4rb20B6FkIJNd7xCD"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:+SSxudD3LnIu8KWyQgxMWP/GBeE=
View all headers

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?

Subject: Re: nohup Versus setsid
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Thu, 12 Sep 2024 11:37 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 11:37:58 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vbujqm$1t0jr$1@news.xmission.com>
References: <vbtqcd$2sce$1@dont-email.me>
Injection-Date: Thu, 12 Sep 2024 11:37:58 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1999483"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

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 to
comp.lang.c...

Subject: Re: nohup Versus setsid
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 12:01 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 14:01:37 +0200
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <vbul72$89jc$1@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Sep 2024 14:01:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="096a4f4876f087f313a0a9fca80aaa56";
logging-data="271980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SDlka3JlySDKHK2Pq8uui"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:NH8qwP8K3QYNEgSeS9Ffp2B7TRI=
In-Reply-To: <vbujqm$1t0jr$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
View all headers

On 12.09.2024 13:37, Kenny McCormack wrote:
> 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 [...], and tell me why we still need nohup when we have setsid?

I don't know the details, but the descriptions look quite different...
nohup - run a command immune to hangups, with output to a non-tty
setsid - run a program in a new session

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

Yes it's old; existing almost from Unix' beginning (at least Version 7).
But I used nohup a couple times, to have the function described above.
(I've never used setsid, never needed it, didn't even know it exists.)

>
> 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).

Well, count me to the minority.

But why are you saying that "job control is now sort of thought of as
an anachronism"?

>
> So, despite what I said 2 paragraphs ago, nohup(1) may be better as a
> recommendation to the newbie.

A non-technical but more fundamental answer can be that nohup is POSIX
standard while the other is not (with all consequences for the general
case, portability, etc.).

Janis

Subject: Re: nohup Versus setsid
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 12:11 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 12:11:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20240912050321.649@kylheku.com>
References: <vbtqcd$2sce$1@dont-email.me>
Injection-Date: Thu, 12 Sep 2024 14:11:35 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fc240c90c706e031471363b92b2225a2";
logging-data="270113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xw4toGLuIzZTyejjxGvfjmU94GdrLhl0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:CrhXBP2tnaZcQaz9nPvWjmjzP00=
View all headers

On 2024-09-12, 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?

Did you notice that this is comp.unix.shell, not comp.linux.shell?

You might use nohup when you're on a system that isn't Linux.

nohup is described in POSIX (and on GNU/Linux systems, it comes from
GNU Coreutils) whereas setsid (the command) is something from util-linux.

$ setsid
-bash: setsid: command not found
$ uname -a
Darwin m1box.example.net 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug
22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64
$ nohup
usage: nohup [--] utility [arguments]

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: nohup Versus setsid
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 22:02 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 22:02:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <vbvod2$esm6$1@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Sep 2024 00:02:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fe8eaca0c36637cab02c0b5baab677cf";
logging-data="488134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/lz7DKdTyg8VKoDlQa+7p"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:S0w0JTID0cCaOxgSokhM5tllpyk=
View all headers

On Thu, 12 Sep 2024 14:01:37 +0200, Janis Papanagnou wrote:

> 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).
>
> I don't know the details, but the descriptions look quite different...
> nohup - run a command immune to hangups, with output to a non-tty
> setsid - run a program in a new session

The effect is supposed to be the same: spawn a background task that will
continue running after you log out.

Subject: Re: nohup Versus setsid
From: vallor
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 23:07 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 23:07:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <vbvs6r$7jlu$1@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Sep 2024 01:07:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bbd4b78101f41a445575eecb61c8aacf";
logging-data="249534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uqY5qGewd49zTYOtufam9"
User-Agent: Pan/0.160 (Toresk; f2b262f; Linux-6.11.0-rc7)
Cancel-Lock: sha1:8z8EgoFnkSM6hjGU/uwoLZXMGEw=
X-Face: +McU)#<-H?9lTb(Th!zR`EpVrp<0)1p5CmPu.kOscy8LRp_\u`:tW;dxPo./(fCl
CaKku`)]}.V/"6rISCIDP`
View all headers

On Thu, 12 Sep 2024 22:02:10 -0000 (UTC), Lawrence D'Oliveiro wrote:

> On Thu, 12 Sep 2024 14:01:37 +0200, Janis Papanagnou wrote:
>
>> 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).
>>
>> I don't know the details, but the descriptions look quite different...
>> nohup - run a command immune to hangups, with output to a non-tty
>> setsid - run a program in a new session
>
> The effect is supposed to be the same: spawn a background task that will
> continue running after you log out.

That's not the only thing that the (POSIX) nohup(1) tool does.

I prefer the simplicity of nohup's behavior, and use it when doing
"big" compiles.

I have a script:
$ cat go.sh
time -p make -j64

So I can:
$ nohup ./go.sh &

Then I can watch for status without flooding the terminal:

$ while : ; do tail nohup.out ; date; sleep 5 ; done

Everybody has their own way of doing things, but this works
on any POSIX system, not just Linux[*].

[*] Though, truth be told, I'm mostly using it to
compile Linux.

--
-Scott System76 Thelio Mega v1.1 x86_64 NVIDIA RTX 3090 Ti
OS: Linux 6.11.0-rc7 Release: Mint 21.3 Mem: 258G
"E Pluribus UNIX."

Subject: Re: nohup Versus setsid
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 23:13 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Thu, 12 Sep 2024 23:13:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <vbvsie$fkeu$3@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
<vbvs6r$7jlu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Sep 2024 01:13:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fe8eaca0c36637cab02c0b5baab677cf";
logging-data="512478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4CGIGKVK7a4Ih6WZ/bCHN"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:KhFmjA31OvYAy0xV02///jaiZiU=
View all headers

On Thu, 12 Sep 2024 23:07:07 -0000 (UTC), vallor wrote:

> On Thu, 12 Sep 2024 22:02:10 -0000 (UTC), Lawrence D'Oliveiro wrote:
>
>> The effect is supposed to be the same: spawn a background task that
>> will continue running after you log out.
>
> That's not the only thing that the (POSIX) nohup(1) tool does.
>
> Then I can watch for status without flooding the terminal:

But then, you cannot do more than one nohup invocation at a time, if one
is already writing to nohup.out.

With setsid, I just specify an output log file for each invocation, and I
can tail that in the usual way, same as you do.

Subject: Re: nohup Versus setsid
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 00:37 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 00:37:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <20240912173141.563@kylheku.com>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
<vbvs6r$7jlu$1@dont-email.me>
Injection-Date: Fri, 13 Sep 2024 02:37:54 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="99dc7076b0b49591e69cd20e1421cb3c";
logging-data="540159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19euhT+kJnQYt0yvwJWXNvfB3NVtwWVsvI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:kK4Ab0Lm+7bjFQViskuoeIKEpjs=
View all headers

On 2024-09-12, vallor <vallor@cultnix.org> wrote:
> On Thu, 12 Sep 2024 22:02:10 -0000 (UTC), Lawrence D'Oliveiro wrote:
>
>> On Thu, 12 Sep 2024 14:01:37 +0200, Janis Papanagnou wrote:
>>
>>> 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).
>>>
>>> I don't know the details, but the descriptions look quite different...
>>> nohup - run a command immune to hangups, with output to a non-tty
>>> setsid - run a program in a new session
>>
>> The effect is supposed to be the same: spawn a background task that will
>> continue running after you log out.
>
> That's not the only thing that the (POSIX) nohup(1) tool does.
>
> I prefer the simplicity of nohup's behavior, and use it when doing
> "big" compiles.
>
> I have a script:
> $ cat go.sh
> time -p make -j64
>
> So I can:
> $ nohup ./go.sh &
>
> Then I can watch for status without flooding the terminal:
>
> $ while : ; do tail nohup.out ; date; sleep 5 ; done
>
> Everybody has their own way of doing things, but this works
> on any POSIX system, not just Linux[*].

I have this:

$ time -p make -j64 | pw &

Where pw is PipeWatch: https://www.kylheku.com/cgit/pw/about/

pw continuously reads its input, and refreshes the terminal
with samples of the input.

When pw is put into the job control background, it knows this,
and avoids writing to the terminal, while continuing to read
standard input, and performing its activities like capturing
triggered snapshots.

When you foreground it, the display refreshes.

pw is not a pager; it does not buffer everything and does not
let you scroll through the history. It captures terminal-window-sized
snapshots consisting of lines.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: nohup Versus setsid
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 01:44 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 03:44:18 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <vc05dj$kvsf$1@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
<vbvs6r$7jlu$1@dont-email.me> <vbvsie$fkeu$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Sep 2024 03:44:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0888291cfb4523e10761248639c3c481";
logging-data="688015"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+xZ/JJETnae1aiMlNuVwx"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:getpZC1X/Usxb0fnV13hp9lKxNI=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vbvsie$fkeu$3@dont-email.me>
View all headers

On 13.09.2024 01:13, Lawrence D'Oliveiro wrote:
> On Thu, 12 Sep 2024 23:07:07 -0000 (UTC), vallor wrote:
>
>> On Thu, 12 Sep 2024 22:02:10 -0000 (UTC), Lawrence D'Oliveiro wrote:
>>
>>> The effect is supposed to be the same: spawn a background task that
>>> will continue running after you log out.
>>
>> That's not the only thing that the (POSIX) nohup(1) tool does.
>>
>> Then I can watch for status without flooding the terminal:
>
> But then, you cannot do more than one nohup invocation at a time, if one
> is already writing to nohup.out.

If it's only the output file that is an issue I seem to recall that
there's a way to write to a different file (unless it's appended to
nohup). A long time passed that I used nohup - I thought there was
an option to define the output file - but if I inspect the specs it
seems that redirection of stdin suffices to choose arbitrary files.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/nohup.html

(Did I misread the POSIX specs?)

> With setsid, I just specify an output log file for each invocation, and I
> can tail that in the usual way, same as you do.

Janis

Subject: Re: nohup Versus setsid
From: Helmut Waitzmann
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 16:35 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 18:35:00 +0200
Organization: A noiseless patient Spider
Lines: 29
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <831q1n3423.fsf@helmutwaitzmann.news.arcor.de>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
<vbvs6r$7jlu$1@dont-email.me> <vbvsie$fkeu$3@dont-email.me>
<vc05dj$kvsf$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Fri, 13 Sep 2024 18:48:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f0e4ad89130e009d4e5de0b67c768f97";
logging-data="1021011"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IsLq60VFxbf4i7kr/ju55pn2suK/Ye+g="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:/bOM/kJHL4i+YsefF5P+CUQOrHE=
sha1:OHjlFfDJjI75lOH+OMjfJeFDhLk=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com>:
>
> A long time passed that I used nohup - I thought there was an
> option to define the output file - but if I inspect the specs it
> seems that redirection of stdin suffices to choose arbitrary
> files.
>

If you substitute stdout for stdin you'll get what the standard
describes in
(<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/nohup.html#tag_20_89_03>):

If standard error is a terminal and standard output is open but
is not a terminal, all output written by the named utility to its
standard error shall be redirected to the same open file
description as the standard output.

nohup a_command ... >> an_arbitrary_file

> (Did I misread the POSIX specs?)
>

Other than that you read "stdin" where the POSIX specs write
"stdout", no.

Subject: Re: nohup Versus setsid
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 16:53 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 18:53:12 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <vc1qlp$v78u$1@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me> <vbujqm$1t0jr$1@news.xmission.com>
<vbul72$89jc$1@dont-email.me> <vbvod2$esm6$1@dont-email.me>
<vbvs6r$7jlu$1@dont-email.me> <vbvsie$fkeu$3@dont-email.me>
<vc05dj$kvsf$1@dont-email.me> <831q1n3423.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Sep 2024 18:53:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3ea0b24cb964025b15904d5f352be98d";
logging-data="1023262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gxwfukOVFsVAFPvbiPVqL"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:aD7j13OXjOGKfytIPWRchec17Zs=
In-Reply-To: <831q1n3423.fsf@helmutwaitzmann.news.arcor.de>
View all headers

On 13.09.2024 18:35, Helmut Waitzmann wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>:
>
>> (Did I misread the POSIX specs?)
>
> Other than that you read "stdin" where the POSIX specs write "stdout", no.

Oh, thanks! (That was actually a typo.)

Janis

Subject: Re: nohup Versus setsid
From: Helmut Waitzmann
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 17:00 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 19:00:45 +0200
Organization: A noiseless patient Spider
Lines: 38
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <83wmjf1oaq.fsf@helmutwaitzmann.news.arcor.de>
References: <vbtqcd$2sce$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Fri, 13 Sep 2024 19:12:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f0e4ad89130e009d4e5de0b67c768f97";
logging-data="1031086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WbR7VAku8dOOXgjAcbVYL33FtLXbXT9E="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:ev8Ee13zg/1/KH4/auso94q9weo=
sha1:NeCp51oKjb3wBf+Ze+qQawg2Lz0=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid>:
> 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?
>

Because there is a real difference between both of them.

"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.

Also, the HUP signal will be ignored regardless of its origin
(terminal driver as well as the "kill(2)" system call).

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.

Also, as the command to be run will leave the terminal session
and thus lose the controlling terminal of the invoker, it won't
be affected by any job control signal sent by the terminal driver
of the invoker's controlling terminal, for example when typing
the interrupt, suspend or quit key on the keyboard no signal will
reach the command to be invoked.

Subject: Re: nohup Versus setsid
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 17:26 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 17:26:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <20240913102557.548@kylheku.com>
References: <vbtqcd$2sce$1@dont-email.me>
<83wmjf1oaq.fsf@helmutwaitzmann.news.arcor.de>
Injection-Date: Fri, 13 Sep 2024 19:26:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="99dc7076b0b49591e69cd20e1421cb3c";
logging-data="1034529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ey9CkDimfhx5RxE+qF4Uv7LTmJyQlogM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:4jzU+tDxXGyh4DgJqwAiMBEzQQ4=
View all headers

On 2024-09-13, Helmut Waitzmann <nn.throttle@xoxy.net> wrote:
> Lawrence D'Oliveiro <ldo@nz.invalid>:
>> 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?
>>
>
> Because there is a real difference between both of them.

Don't confuse low drop-out with too many facts.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: nohup Versus setsid
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 13 Sep 2024 22:32 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: nohup Versus setsid
Date: Fri, 13 Sep 2024 22:32:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <vc2eiq$12592$11@dont-email.me>
References: <vbtqcd$2sce$1@dont-email.me>
<83wmjf1oaq.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Sep 2024 00:32:59 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f0b3208cd64aa384126f587d0af4cdfe";
logging-data="1119522"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UFBN97v64KIKp0Ch4Cunv"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:90bYWlBZnw7a+5FQhdy8aZZtK3k=
View all headers

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.

1

rocksolid light 0.9.8
clearnet tor