Date: 26 Apr 1998 23:00:15 -0000 From: Jason Nordwick <nordwick@scam.XCF.Berkeley.EDU> To: geoffr@globalserve.net Cc: questions@FreeBSD.ORG Subject: Re: Return Codes Multiplied by 256 Message-ID: <19980426230015.17590.qmail@xcf.berkeley.edu> In-Reply-To: geoffr@globalserve.net on 4/26/1998 to questions@FreeBSD.ORG <35438F8E.63B2CCBD@globalserve.net> References: <35438F8E.63B2CCBD@globalserve.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Geoffrey Robinson, on Sun 4/26/1998, wrote the following: > > I'm writing a front end CGI to interface with another program I've written. > The front end program uses popen() to create a pipe to the first program > and gets the return code from pclose(). The program that is piped to uses > exit() to return an error code other than 0 if a problem occurs. At first I > thought I was getting garbage values returned but then I discovered that > all the returned where multiplied by 256. > > If I divide the value returned by 256 I get one of the return codes I > specified in my program but I'm afraid something may be wrong if I'm > getting it back as a multiple of 256. Can somebody verify that this is > supposed to happen, or not. > wait4 returns the exit status encoded (since you only get like 8 bits of status information back) so you need to use the WEXITSTATUS() on the pid_t returned by pclose (The exit status is returned in the second 8 bits, I think, but that is really irrelevant). You should also use the WIF.*() macros to test the exit conditions. > Thanks. > > -- > Geoffrey Robinson > geoffr@globalserve.net > Oakville, Ontario, Canada. > jay -- Join the FreeBSD Revolution. Support the FSF, buy GNU. http://xcf.berkeley.edu/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980426230015.17590.qmail>