[comp.sources.bugs] Perl apology -- and enhancement

vic@zen.UUCP (Victor Gavin) (04/27/88)

I said:

> Can anyone fill me in on the current status of perl as we still haven't got it
> working.

> We are running an HP9000 model 840 with HPUX 1.2, perl is at patchlevel 29.

I now say:

Sorry folks, I f***ed up (horrific sounds of programmer hitting himself).
I though I had it all re-compiled and linked -- I hadn't.

After fixing the problem that stopped it from linking (HPUX doesn't have the
functions set[er][gu]id()) the tests ran perfectly -- except for failing
symlink(), which is present in release 2.0 of HPUX for the series 800.

Whilst I'm here, for anyone that's interested, here's some code that will fix
(system "/bin/sh -c 'exit 1'") so that it returns 1 and not 256:

....................... cut along the dotted line ..............................
*** arg.c.orig	Wed Apr 27 14:50:31 1988
--- arg.c	Sat Apr 16 09:18:34 1988
***************
*** 2180,2185
  		;
  	    if (maxarg == -1)
  		argflags = -1;
  	    signal(SIGINT, ihand);
  	    signal(SIGQUIT, qhand);
  	    statusvalue = argflags;

--- 2180,2211 -----
  		;
  	    if (maxarg == -1)
  		argflags = -1;
+ #ifdef	hpux
+ 	    /* the return value from this command is not the same as that
+ 	     * produced by shell, in particular
+ 	     *		system("/bin/sh -c 'exit 1'") returns 256 not 1
+ 	     *
+ 	     * HPUX return three different values through the parameter to
+ 	     * wait() -- taken as a 16 bit integer.
+ 	     *
+ 	     *	1.  If lower 8 bits are FF then process stopped and
+ 	     *	    reason is in upper 8 bits.
+ 	     *
+ 	     *	2.  If lower 8 bits are 00 then process exit()'ed and
+ 	     *	    status is in upper 8 bits.
+ 	     *
+ 	     *	3.  If upper 8 bits are 00 then process was hit by signal
+ 	     *	    which is in lower 8 bits.
+ 	     *
+ 	     */
+ 	    else if ( !(argflags & (int)0xFF) )
+ 	    {
+ 	      /* the program terminated so transpose the 8 bits to get the
+ 	       * status
+ 	       */
+ 	      argflags = ((argflags>>8)&0xFF) | ((argflags&0xFF)<<8);
+ 	    }
+ #endif
  	    signal(SIGINT, ihand);
  	    signal(SIGQUIT, qhand);
  	    statusvalue = argflags;
................................................................................



--
Victor Gavin                         vic@zen.co.uk || ..!mcvax!ukc!zen.co.uk!vic
Computer Psychoanalyst               Zengrange Limited, Leeds LS9 8DB, England

lwall@devvax.JPL.NASA.GOV (Larry Wall) (04/30/88)

In article <1231@zen.UUCP> vic@zen.UUCP (Victor Gavin) writes:
: Whilst I'm here, for anyone that's interested, here's some code that will fix
: (system "/bin/sh -c 'exit 1'") so that it returns 1 and not 256:

PLEASE DO NOT APPLY THIS PATCH!  The return value of 1 should indicate
that the shell died of being sent a HUP signal.  To get the status value
as returned by the program, do a >>8.  I do believe this is documented.

Even if you think this behavior is wrong, please don't make your perl
incompatible with everyone else's.  Some poor critter on your machine is
going to write a script that depends on it and then post it to the world.
Critter will then get fried in a semi-unjustified manner.

Your's for a less desperate world,

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov