zsh-workers
 help / color / mirror / code / Atom feed
* Re: zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X
@ 2009-07-22 18:18 Martin Cracauer
  2009-07-25 18:58 ` Bart Schaefer
  0 siblings, 1 reply; 28+ messages in thread
From: Martin Cracauer @ 2009-07-22 18:18 UTC (permalink / raw)
  To: zsh-workers


Hi, a friend pointed me to this discussion and I took it as an
opportunity to fix some minor issues with my SIGINT page.

I'd like to comment on this one:

Bart Schaefer wrote:
> Further I think Cracauer is very wrong here:
> 
>   Do nothing special when SIGINT appears while you wait for a
>   child. You
>   don't even have to remember that one happened.
>   ...
>   Look at WIFSIGNALED(status) and WTERMSIG(status) to tell whether the
>   child says "I exited on SIGINT: in my opinion the user wants the
>   shellscript to be discontinued".
> 
> This is plain nonsense.
> 
> Not only does this potentially contradict a caller's explicit request
> to ignore SIGINT, but the script should not exit 130 every time any
> child exits 130.  It should exit only when SIGINT was received *by the
> script*.  "kill -INT ..." of the child should not cause the shell to
> behave as if it was interrupted.  Try it with bash.

You are correct (except that the numeric exit of 130 means nothing,
you have to use WIFSIGNALED but I assume you know that and just
shortcut it for the message).

There would be two ways of dealing with this:

1) when a child got killed with SIGINT, always abort the script
2) do that only when the shell itself also had received a SIGINT while
   that child was executing in the foreground

I have actually implemented 2) in FreeBSD's shell and bash also does
2).  However, I had skipped over that detail when writing the webpage.
The have has been corrected.

(let me know if you want credit on the page)

%%

More bits from the discussion:
>> BTW, I wonder why typing Ctrl-g in emacs sends SIGINT to the parent
>> under Mac OS X, but not under Linux.
>
> Some ancestry of BSD vs. SYSV tty process group semantics, I expect.

Looks like it's more complicated.

Both FreeBSD and Linux place both the shell and emacs in the same
progress group.

However, using strace on Linux you can see the SIGINT delivered to the
shell if you do

#! /bin/sh
cat
echo survived

And Control-C out of the cat.

And not when the callee is emacs.

On first sight it looks like the Linux kernel changes semantics based
on whether the terminal is in cooked mode or not.  Possibly in an
attempt to help a bit with the "what to do on SIGINT in interactive
programs" mess we are dealing with here.

If so, that explains why Linux users never flamed about the
wrong-exit-after-emacs problem.  If the kernel never tells the shell
anything about the SIGINT when the foreground program is in curses
mode the problem won't appear.

If so, that would be bad news for shellscripts calling programs that
do curses but just exit on SIGINT (lynx comes to mind).

Thanks
Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org>   http://www.cons.org/cracauer/
FreeBSD - where you want to go, today.      http://www.freebsd.org/


^ permalink raw reply	[flat|nested] 28+ messages in thread
* zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X
@ 2009-07-12 20:59 Vincent Lefevre
  2009-07-12 21:50 ` Bart Schaefer
  0 siblings, 1 reply; 28+ messages in thread
From: Vincent Lefevre @ 2009-07-12 20:59 UTC (permalink / raw)
  To: zsh-workers

Hi,

I've found a problem with zsh 4.3.10 (and some previous versions, as
this bug has occurred for quite a long time, and I've identified it
only now). I could trigger it only under Mac OS X (version 10.4.11).

Consider a script with a line like

  /usr/bin/emacs -Q -nw

or

  /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs -Q -nw

(the problem doesn't depend on the version of emacs, e.g. 21 or 22).

Run it with:

  zsh -f ./script

and type Ctrl-G in Emacs. Then zsh terminates with a SIGINT, killing
Emacs at the same time.

This problem also occurs with ksh 1993-12-28 p, but not with bash.
With zsh 4.2.3, the SINGINT occurs only after Emacs terminates (e.g.
by quitting it with C-x C-c).

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2009-07-28 21:31 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-22 18:18 zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X Martin Cracauer
2009-07-25 18:58 ` Bart Schaefer
2009-07-26  6:24   ` Philippe Troin
2009-07-26 21:14     ` Bart Schaefer
2009-07-27 23:10   ` Martin Cracauer
2009-07-28  4:29     ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2009-07-12 20:59 Vincent Lefevre
2009-07-12 21:50 ` Bart Schaefer
2009-07-13  0:43   ` Vincent Lefevre
2009-07-13  2:36     ` Bart Schaefer
2009-07-13 18:39       ` Peter Stephenson
2009-07-16 16:24         ` Vincent Lefevre
2009-07-18  5:29           ` Bart Schaefer
2009-07-18 10:16             ` Vincent Lefevre
2009-07-18 18:16               ` Bart Schaefer
2009-07-19 18:03                 ` Bart Schaefer
2009-07-19 19:15                   ` Bart Schaefer
2009-07-19 20:14                     ` Bart Schaefer
2009-07-19 20:41                       ` Peter Stephenson
2009-07-18 18:35               ` Bart Schaefer
2009-07-18 23:09                 ` Vincent Lefevre
2009-07-19  9:51                   ` Vincent Lefevre
2009-07-19 16:32                     ` Bart Schaefer
2009-07-19 22:24                       ` Vincent Lefevre
2009-07-19 18:31                   ` Bart Schaefer
2009-07-20  8:31                     ` Vincent Lefevre
2009-07-22  2:58                       ` Eric Blake
2009-07-22  8:16                         ` Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).