Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

signal weirdness fix



-----BEGIN PGP SIGNED MESSAGE-----

Remember that odd behaviour I reported, that zsh thought it received a
signal actually sent to its foreground job?

This patch limits it to SIGHUP, SIGINT and SIGQUIT, and disables this
behaviour completely in non-interactive shells.  I think this is a good
semantic.  Unfortunately the semantic we actually want (did the signal
actually originate at the tty) is impossible to implement, but I think
this is a close approximation.

 -zefram

      Index: Src/jobs.c
      ===================================================================
      RCS file: /home/zefram/usr/cvsroot/zsh/Src/jobs.c,v
      retrieving revision 1.10
      diff -c -r1.10 jobs.c
      *** Src/jobs.c	1996/11/03 00:48:18	1.10
      --- Src/jobs.c	1996/11/26 00:01:11
      ***************
      *** 180,194 ****
        
            /* WHY DO WE USE THE RETURN STATUS OF PROCESS GROUP LEADER HERE? */
            /* If the foreground job got a signal, pretend we got it, too.   */
      !     if (inforeground && WIFSIGNALED(status)) {
      ! 	if (sigtrapped[WTERMSIG(status)]) {
        	    /* Run the trap with the error flag unset.
        	     * Errflag is set in printjobs if the jobs terminated
        	     * with SIGINT.  I don't know why it's done there and
        	     * not here.   (PWS 1995/06/08)
        	     */
        	    errflag = 0;
      ! 	    dotrap(WTERMSIG(status));
        	    /* We keep the errflag as set or not by dotrap.
        	     * This is to fulfil the promise to carry on
        	     * with the jobs if trap returns zero.
      --- 180,198 ----
        
            /* WHY DO WE USE THE RETURN STATUS OF PROCESS GROUP LEADER HERE? */
            /* If the foreground job got a signal, pretend we got it, too.   */
      !     if (inforeground && interact && WIFSIGNALED(status)) {
      ! 	int sig = WTERMSIG(status);
      ! 
      ! 	if(sig != SIGHUP && sig != SIGINT && sig != SIGQUIT)
      ! 	    ;
      ! 	else if (sigtrapped[sig]) {
        	    /* Run the trap with the error flag unset.
        	     * Errflag is set in printjobs if the jobs terminated
        	     * with SIGINT.  I don't know why it's done there and
        	     * not here.   (PWS 1995/06/08)
        	     */
        	    errflag = 0;
      ! 	    dotrap(sig);
        	    /* We keep the errflag as set or not by dotrap.
        	     * This is to fulfil the promise to carry on
        	     * with the jobs if trap returns zero.
      ***************
      *** 198,205 ****
        	     */
        	    if (errflag)
        		breaks = loops;
      ! 	} else if (WTERMSIG(status) == SIGINT ||
      ! 		   WTERMSIG(status) == SIGQUIT) {
        	    breaks = loops;
        	    errflag = 1;
        	}
      --- 202,208 ----
        	     */
        	    if (errflag)
        		breaks = loops;
      ! 	} else if (sig == SIGINT || sig == SIGQUIT) {
        	    breaks = loops;
        	    errflag = 1;
        	}

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMpo0q3D/+HJTpU/hAQFClQP/XBLb4IYMjcCmXc+7jneECAAcHJZvNs22
Yoa2gxrdSM78jHj1NUHN3V78LAqF6wITB5bspgT5sJ1hfyBlR+eQSvKd0imyDi9M
4YxtkUCaDX/GZLU+wiws4GSD7DsCD4c2yiAC+B8WlZ4WXGCKy8r++9h5DVIn4K1p
HoA+C4q4IR4=
=QpBl
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author