zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu
Subject: Re: signal handling bug
Date: Tue, 16 Apr 1996 17:56:55 +0200	[thread overview]
Message-ID: <199604161556.RAA02778@hydra.ifh.de> (raw)
In-Reply-To: "hzoli@cs.elte.hu"'s message of "Sun, 31 Mar 1996 20:14:17 MET." <199603311814.UAA00723@hzoli.ppp.cs.elte.hu>

hzoli@cs.elte.hu wrote:
> % zsh -c 'trap "echo Interrupt ; exit" INT ; while true ; do sleep 1 ; done'
> 
> After applying the patches, this is interruptible, but the trap is not
> executed (and it is interruptible even if I use trap - INT).

I was about to report failure when I had an idea (pity this doesn't
happen very often) and I've managed to fix the first half of the
problem, so what Robert the Bruce said is probably right.

The problem was the test for whether the job that just ran was in the
foreground:  it was relying on the job handling code, so didn't work
in a non-interactive shell.  I've separated the job handling part out
and set `inforeground' in updatestatus() simply according to whether
we are using the status of the current job to update the global status
variable, which sounds pretty plausible to me.  inforeground is later
tested to see if the trap should be run.

This doesn't fix the other half of the problem, that the job is
interruptible when supposedly ignoring SIGINT.  That's certainly a
separate problem, possibly beyond my signal knowledge (meaning of
course ``knowledge of signals'', rather than ``notable knowledge''),
but I'll probably take a look at it anyway.

Point to note: ksh M-11/16/88f (the most widespread version of ksh
'88) has the same problem --- the problem reported by Zoltan after the
previous set of patches, that is --- so we should feel either smug or
uneasy.

This patch is intended to go on top of all the other trap patches, of
course.  I don't know whether or not it actually needs them, but it's
pointless to use it without the others.

*** Src/jobs.c.spec	Mon Apr 15 11:45:03 1996
--- Src/jobs.c	Tue Apr 16 17:36:50 1996
***************
*** 123,140 ****
  	    return;
      } else {                   /* job is done, so remember return value */
  	lastval2 = val;
! 	/* If last process was run in the currrent shell, keep old status */
! 	if (job == thisjob && !(jn->stat & STAT_CURSH))
! 	    lastval = val;
      }
  
      pgrp = gettygrp();           /* get process group of tty      */
  
!     /* is this job in the foreground */
!     if (jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))
! 	inforeground = 1;
! 
!     if (inforeground && !ttyfrozen && !val && !jn->stty_in_env)
  	gettyinfo(&shttyinfo);
      adjustwinsize();             /* check window size and adjust if necessary */
      if (somestopped && jn->stat & STAT_SUPERJOB)
--- 123,142 ----
  	    return;
      } else {                   /* job is done, so remember return value */
  	lastval2 = val;
! 	/* If last process was run in the current shell, keep old status
! 	 * and let it handle its own traps
! 	 */
! 	if (job == thisjob && !(jn->stat & STAT_CURSH)) {
! 	  lastval = val;
! 	  inforeground = 1;
! 	}
      }
  
      pgrp = gettygrp();           /* get process group of tty      */
  
!     /* is this job in the foreground of an interactive shell? */
!     if ((jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1)) &&
! 	!ttyfrozen && !val && !jn->stty_in_env)
  	gettyinfo(&shttyinfo);
      adjustwinsize();             /* check window size and adjust if necessary */
      if (somestopped && jn->stat & STAT_SUPERJOB)
-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



  reply	other threads:[~1996-04-16 16:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-13 22:59 Zoltan Hidvegi
1996-03-14  8:29 ` Peter Stephenson
1996-03-31 18:14   ` Zoltan Hidvegi
1996-04-16 15:56     ` Peter Stephenson [this message]
1996-06-20 23:09 Zoltan Hidvegi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199604161556.RAA02778@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).