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

Re: Weird problem with trn's Configure script



wayne@xxxxxxxxx wrote:
> I finally tested trn's Configure script with zsh enulating sh and I found
> one weird problem.  The script is trying to ensure that it is being run
> by sh, not csh, so it does this test (tweaked for simplicity):
> 
> 	(exit $?0) || echo You are not running sh
> 
> Under zsh 3.0pre6 in either zsh or sh compatibility mode this causes a
> large chunk of the script to get executed multiple times.

Looks like I'm going to get to this before Zoltan...

This is an extremely typical symptom of an exit() being called instead
of _exit() in a forked subshell which never exec'd.  This occurs most
often on System-V-like systems.  (I learnt all that from Bart.)

Knowing that, it's easy to fix.  Luckily, most regular exits go
through zexit(), though I caught one other at the tail end of a list.
I think most other exits in the code are abnormal, so aren't such a
problem, but there are possibly others which need the treatment.  To
the best of my knowledge checking that we still have the original pid
before an exit is (a) completely safe (b) quick.  I tested this on
OSF/1 3.0 which showed the problem.

(This is actually about the third round of _exit() fixes.  I apologise
for not fixing this on the last round; I thought about some fairly
similar things but obviously didn't check this.  I expect it's been
there since zsh prehistory.)

*** Src/builtin.c.exit	Mon Aug  5 14:07:34 1996
--- Src/builtin.c	Mon Aug  5 14:38:39 1996
***************
*** 4610,4616 ****
      }
      if (sigtrapped[SIGEXIT])
  	dotrap(SIGEXIT);
!     exit(val);
  }
  
  /* . (dot), source */
--- 4610,4619 ----
      }
      if (sigtrapped[SIGEXIT])
  	dotrap(SIGEXIT);
!     if (mypid != getpid())
! 	_exit(val);
!     else
! 	exit(val);
  }
  
  /* . (dot), source */
*** Src/exec.c.exit	Mon Aug  5 14:06:56 1996
--- Src/exec.c	Mon Aug  5 14:44:53 1996
***************
*** 569,575 ****
  	    if (lastval && isset(ERREXIT)) {
  		if (sigtrapped[SIGEXIT])
  		    dotrap(SIGEXIT);
! 		exit(lastval);
  	    }
  	}
  
--- 569,578 ----
  	    if (lastval && isset(ERREXIT)) {
  		if (sigtrapped[SIGEXIT])
  		    dotrap(SIGEXIT);
! 		if (mypid != getpid())
! 		    _exit(lastval);
! 		else
! 		    exit(lastval);
  	    }
  	}
  

-- 
Peter Stephenson <pws@xxxxxx>       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.



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