Subject: Re: /bin/sh, /bin/csh and the '^C'
To: Andrew Gillham <gillhaa@ghost.whirlpool.com>
From: Andrew Brown <atatat@atatdot.net>
List: current-users
Date: 04/05/1999 23:15:40
>Ok, now that we're in 1.4_ALPHA, I'll complain again.. :-)
>With empty /etc/csh.* and no /root/.cshrc and /root/.login, I
>*still* see the control-c when I type it! (but it interrupts)
># ^C
># ^C
>
>If I use /bin/tcsh, I get the interrupt, but it does not print
>the '^C' also.
>This has been attributed to a broken /bin/sh in the past, but
>it is still broken on my machines.  I see it on i386/vax/alpha/next68k
>all with wscons.

i've always attributed it to the fact that tcsh (and bash, fwiw) both
set the terminal into "raw" mode (with echo off as well?), while sh
and csh, afaik, either only set it to cbreak mode, or just tell it to
ignore signals.  in apps that i've written, i usually have the sigint
handler print "\b \b\b \b\r\n" to erase the ^C garbage.

tcsh definitely fiddles about a bit and sets

lflags: -icanon -iexten -echo -echok -pendin 
iflags: -inlcr
cchars: dsusp = <undef>; eof = <undef>; lnext = <undef>;
	reprint = <undef>; susp = <undef>; werase = <undef>;

try this with any shell and it oughta give some clues as to what it's
doing.

andrew@noc::ttyp0:~> stty -a
speed 38400 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl oxtabs
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -mdmbuf
        -cdtrcts
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
        min = 1; quit = ^\; reprint = ^R; start = ^Q; status = <undef>;
        stop = ^S; susp = ^Z; time = 0; werase = ^W;
andrew@noc::ttyp0:~> ( sleep 3 ; stty -a ) &
[2] 11220
andrew@noc::ttyp0:~> speed 38400 baud; 24 rows; 80 columns;
lflags: -icanon isig -iexten -echo echoe -echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
        -extproc
iflags: -istrip icrnl inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl oxtabs
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -mdmbuf
        -cdtrcts
cchars: discard = ^O; dsusp = <undef>; eof = <undef>; eol = <undef>;
        eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U;
        lnext = <undef>; min = 1; quit = ^\; reprint = <undef>;
        start = ^Q; status = <undef>; stop = ^S; susp = <undef>;
        time = 0; werase = <undef>;

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."