Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: die() exit status and printing $1,$2... in the debugger Message-ID: <10993@jpl-devvax.JPL.NASA.GOV> Date: 10 Jan 91 19:55:54 GMT References: <3000@yarra-glen.aaii.oz.au> <10980@jpl-devvax.JPL.NASA.GOV> <20541:Jan1017:37:5091@kramden.acf.nyu.edu> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 28 In article <20541:Jan1017:37:5091@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: : In article <10980@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: : > It would seem that your compiler or run-time system is hosed. The : > statement in fatal() in util.c is : > statusvalue >>= 8; /* is an unsigned short */ : > exit((int)(errno?errno:(statusvalue?statusvalue:255))); : > How can that return a 0, I ask you? : : Well, since you ask, it can return 0 on most machines if errno is a : nonzero multiple of 256, or if errno is 0 and statusvalue is a nonzero : multiple of 256. Hmm, yes, but I don't think that's what's going on here. On any machine with 16-bit shorts, statusvalue can't be a nonzero multiple of 256 because of the preceding shift, and I don't know of any machines with errno's greater than 255. It's vaguely possible that we have a garbaged errno, but I think it's more likely that we're seeing an endian problem. There's an alternate fatal() function with a similar exit(), but without the cast to (int). Since statusvalue is a short, it might be going into the wrong half of the int argument to exit. I'll replace both exit statements with: exit((int)((errno&255)?errno:((statusvalue&255)?statusvalue:255))); That should fix it, one way or the other. Larry