Article View: news.software.readers
Article #17568trn, sh -c and interrupts-- bug or misfeature?
From: john hood
Date: Wed, 15 Nov 1995 00:00
Date: Wed, 15 Nov 1995 00:00
70 lines
2390 bytes
2390 bytes
so, i've been having this problem with trn for a couple of years now, and i'm finally getting motivated to try and fix it. 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. --john hood # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # t # echo x - t sed 's/^X//' >t << 'END-of-t' X#!/bin/sh X# X# test sig handling in sh -c X# X# create second script XTF=/tmp/test.$$ Xcat > $TF <<\/EOF X#!/bin/sh Xecho -e "shell c flags: $-" Xtrap Xtrap : 2 3 Xecho "Type ^C and ^\\" Xfor i in a b c d e Xdo X sleep 1 X echo shell c: $i Xdone X/EOF Xchmod a+x $TF X Xif [ $# != 1 ] Xthen X echo "$0 shell-to-test" X exit 1 Xfi XSHELL=$1 Xecho -e "shell a flags: $-" Xtrap Xtrap : 2 3 X$SHELL -c "echo shell b flags: $-; trap; $TF" Xecho 'shell a exit: ' $? Xrm $TF END-of-t exit
Technical Details
Message-ID:
<48c54t$qe3@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-mailShow Full Headers
Complete Article Headers
Message-ID: <48c54t$qe3@sundog.tiac.net> Subject: trn, sh -c and interrupts-- bug or misfeature? Date: Wed, 15 Nov 1995 00:00:00 +0000 From: cgull@smoke.marlboro.vt.us (john hood) 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: 119381860 Organization: interstellar Newsgroups: comp.unix.shell,news.software.readers