From owner-freebsd-questions Sun Apr 26 16:12:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA03539 for freebsd-questions-outgoing; Sun, 26 Apr 1998 16:05:59 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from xcf.berkeley.edu (scam.XCF.Berkeley.EDU [128.32.43.201]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id PAA03102 for ; Sun, 26 Apr 1998 15:59:00 -0700 (PDT) (envelope-from nordwick@xcf.berkeley.edu) Received: (qmail 17591 invoked by uid 27268); 26 Apr 1998 23:00:15 -0000 Date: 26 Apr 1998 23:00:15 -0000 Message-ID: <19980426230015.17590.qmail@xcf.berkeley.edu> From: Jason Nordwick MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: geoffr@globalserve.net Cc: questions@FreeBSD.ORG Subject: Re: Return Codes Multiplied by 256 In-Reply-To: geoffr@globalserve.net on 4/26/1998 to questions@FreeBSD.ORG <35438F8E.63B2CCBD@globalserve.net> References: <35438F8E.63B2CCBD@globalserve.net> X-Mailer: VM 6.32 under Emacs 19.34.1 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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