zsh-workers
 help / color / mirror / code / Atom feed
* Weird problem with trn's Configure script
@ 1996-08-04 21:28 Wayne Davison
  1996-08-04 22:39 ` Zoltan Hidvegi
  1996-08-05 13:08 ` Weird problem with " Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Wayne Davison @ 1996-08-04 21:28 UTC (permalink / raw)
  To: zsh-workers

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.  Try the
following script:

	#!/local/bin/zsh
	(exit) || echo This should not be seen
	echo we are here

With pre6 you'll see the "we are here" statement twice!  In pre3 it
did something a little weirder:

	./testscript: command not found: ould [4]
	we are here

I haven't had a chance to check the code, but it looks like the closing
paren isn't being parsed correctly in this instance.  This only seems
to happen if the last command in ()'s is an exit.

..wayne..


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

* Re: Weird problem with trn's Configure script
  1996-08-04 21:28 Weird problem with trn's Configure script Wayne Davison
@ 1996-08-04 22:39 ` Zoltan Hidvegi
  1996-08-05  7:47   ` Weird problem with zsh running " Wayne Davison
  1996-08-05 13:08 ` Weird problem with " Peter Stephenson
  1 sibling, 1 reply; 4+ messages in thread
From: Zoltan Hidvegi @ 1996-08-04 22:39 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers

> 	#!/local/bin/zsh
> 	(exit) || echo This should not be seen
> 	echo we are here
> 
> With pre6 you'll see the "we are here" statement twice!  In pre3 it
> did something a little weirder:
> 
> 	./testscript: command not found: ould [4]
> 	we are here
> 
> I haven't had a chance to check the code, but it looks like the closing
> paren isn't being parsed correctly in this instance.  This only seems
> to happen if the last command in ()'s is an exit.

I cannot reproduce this with any version of zsh.  Are you sure that it is a
zsh bug?  I cannot imagine what can cause such a problem.  Isn't it a
compiler bug?  What system/compiler do you use?  Isn't there something
unusual in your /etc/zshenv?

Zoltan


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

* Re: Weird problem with zsh running trn's Configure script
  1996-08-04 22:39 ` Zoltan Hidvegi
@ 1996-08-05  7:47   ` Wayne Davison
  0 siblings, 0 replies; 4+ messages in thread
From: Wayne Davison @ 1996-08-05  7:47 UTC (permalink / raw)
  To: Zoltan Hidvegi; +Cc: zsh-workers

Zoltan Hidvegi writes:
> I cannot reproduce this with any version of zsh.

The problem turns out to be that the zexit() routine is calling exit()
from a forked process when it should be calling _exit().  When this
occurs, weird things happen to the open file handles, and the file
handle that is reading the input file gets changed somehow and ends
up re-reading part of the input file.

I don't know enough about the inner workings of the exec system to
know what test to make in zexit() to let it choose the right exit
function, so I cannot supply a patch.

> What system/compiler do you use?

Just so you know, I'm running zsh under Solaris x86 2.5 compiled with
gcc 2.7.2.

..wayne..


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

* Re: Weird problem with trn's Configure script
  1996-08-04 21:28 Weird problem with trn's Configure script Wayne Davison
  1996-08-04 22:39 ` Zoltan Hidvegi
@ 1996-08-05 13:08 ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 1996-08-05 13:08 UTC (permalink / raw)
  To: Wayne Davison, Zsh hackers list

wayne@clari.net 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@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.


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

end of thread, other threads:[~1996-08-05 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-04 21:28 Weird problem with trn's Configure script Wayne Davison
1996-08-04 22:39 ` Zoltan Hidvegi
1996-08-05  7:47   ` Weird problem with zsh running " Wayne Davison
1996-08-05 13:08 ` Weird problem with " Peter Stephenson

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).