NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Shell script terminates when spawning and killing a background shell process



    Date:        Sat, 18 Jul 2026 18:19:56 +0200
    From:        Gerhard Rieger <gerhard%rieger-priv.org@localhost>
    Message-ID:  <659e6148-7a90-41c4-82a6-e8c8c6e5e4fb%rieger-priv.org@localhost>

  | Well, the remaining point is not about ksh but that this happens with 
  | default /bin/sh which one might expect to be stable.

The outer shell is irrelevant, any shell will (or should) be killed
if sent a SIGTERM (and the script does not trap or ignore it).

But if you change that internal ksh (the one that the script kills)
to some other shell (bash, sh, probably anything else at all), then it
should make no difference what shell is running the outer script, other
shells won't kill their parent when they are killed (and most won't still
even exist with such a simple command to run, they'd simply exec sleep
and the sleep process would be a child of the outer script, rather than
a grandchild, and it would be what was killed).

I understand this is just a simple test of some other more complicated
script, and it is that script that is having the issue you need to solve.
For that my recommendation is just to avoid using /bin/ksh (on NetBSD)
for just about anything not simplistic - if the script needs a ksh variant,
install one of the others from pkgsrc (there are a whole bunch to choose
from), or perhaps bash.

kre





Home | Main Index | Thread Index | Old Index