Article View: news.software.readers
Article #17585Re: trn, sh -c and interrupts-- bug or misfeature?
From: john hood
Date: Thu, 16 Nov 1995 00:00
Date: Thu, 16 Nov 1995 00:00
56 lines
2964 bytes
2964 bytes
In article <48dtgj$ftb@hg.oro.net>, Ralph Jennings <knowbudy@au.oro.net> wrote:
>john hood (cgull@smoke.marlboro.vt.us) wrote:
>: with /bin/sh on DEC OSF/1 v1.3 and 2.0 (i don't know about later
>: versions), and every variant of the Almquist shell I've used on Linux,
>: NetBSD and FreeBSD, a SIGINT from the keyboard will kill the shell, or
>: at least cause it to to exit, while it's waiting for a child in 'sh -c
>: command'. every other shell i've tried, except for a fairly antique
>: bash, ignores the signal.
>
>: this causes considerable annoyance in trn, which uses sh -c to get
>: Pnews started. When you hit ^G in emacs or ^C in vi, you have a
>: problem...sadly, there is no simple, general workaround/fix for trn.
>
>: now, i'm not a shell wizard, and i can't find any documentation that
>: says that this is legitimate or that it's not. it's not a subtle
>: problem; it's hard for me to believe nobody's noticed it. :)
>
>: So, shell wizards: bug or misfeature? simple test script below.
>
>Feature, you can use ^C to kill the program if you decide
> that you don't want to wait for it finish doing what it's
> doing. It's a feature for all of us impatient people.
no, you haven't got it, you're describing something slightly
different. that's an interactive feature.
>Use trap like this, if you don't like that feature.
>
>trap '' <interupts>
>
>using trap with a : like you were makes the shell do nothing
> but all child processes get terminated. Using it with a
> null tells even the child processes to ignore it.
trn essentially does fork()/exec("sh", "sh", "-c", Pnewsstring), where
the last string is usually "Pnews" but can be redefined by the user.
Pnews is a shell script.
trn can't ignore SIGINT before execing. Pnews wants to use it, and
since it's a shell script, it can't turn it back on by itself. trn
and Pnews are both working fine in this instance-- it's that sh -c in
the middle that's breaking, or so i think. we can't tack "exec " onto
the front of Pnewsstring to get rid of it, because Pnewsstring may be
a list of commands.
the traps in my test script are just there to keep the real problem
from getting obscured; they do pretty much what trn and Pnews do, too.
--jh
--
John Hood Kosh-- just *see* it.
cgull@smoke.marlboro.vt.us
Technical Details
Message-ID:
<48eca8$mc@sundog.tiac.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.unix.shell.mbox.zip!not-for-mailReferences:
<48c54t$qe3@sundog.tiac.net> <48dtgj$ftb@hg.oro.net>Show Full Headers
Complete Article Headers
Message-ID: <48eca8$mc@sundog.tiac.net> Subject: Re: trn, sh -c and interrupts-- bug or misfeature? Date: Thu, 16 Nov 1995 00:00:00 +0000 From: cgull@smoke.marlboro.vt.us (john hood) References: <48c54t$qe3@sundog.tiac.net> <48dtgj$ftb@hg.oro.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.unix.shell.mbox.zip!not-for-mail X-Deja-AN: 119439460 Organization: interstellar Newsgroups: comp.unix.shell,news.software.readers