From owner-freebsd-questions Sat Jul 21 9:57:27 2001 Delivered-To: freebsd-questions@freebsd.org Received: from beta.root-servers.ch (gamma.root-servers.ch [195.49.62.126]) by hub.freebsd.org (Postfix) with SMTP id AE4A437B405 for ; Sat, 21 Jul 2001 09:57:21 -0700 (PDT) (envelope-from gabriel_ambuehl@buz.ch) Received: (qmail 91759 invoked from network); 21 Jul 2001 16:57:20 -0000 Received: from dclient62-2-106-17.hispeed.ch (HELO athlon550) (62.2.106.17) by beta.root-servers.ch with SMTP; 21 Jul 2001 16:57:20 -0000 Date: Sat, 21 Jul 2001 18:58:31 +0200 From: Gabriel Ambuehl X-Mailer: The Bat! (v1.53bis) Educational Organization: BUZ Internet Services X-Priority: 3 (Normal) Message-ID: <64104717866.20010721185831@buz.ch> To: freebsd-questions@freebsd.org Subject: WEXITSTATUS yields strange results MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG -----BEGIN PGP SIGNED MESSAGE----- Hello, I'm trying to get the argument a child (created with vfork() + exec() so not a copy of the parent), supplied to it's exit (or return, for that matter) statement. pid_t pstat; do { pid = waitpid(dual_pipe->pid, &pstat, 0); } while (pid == -1 && errno == EINTR); /* Remove the entry from the linked list. */ if (last == NULL) { pidlist = dual_pipe->next; } delete(dual_pipe); return (pstat); Now the first thing that confuses me is that WIFEXITED(pstat) sometimes returns true, whereas other times I get WIFSIGNALED(pstat)=true which doesn't make much sense to me as the child I use for testing is so dumb simple that it is almost impossible that it does something illegal (I'm running it in a self written bidirectional popen() and I always get to see all the data I should). In any case, it for sure doesn't dump core as there's no core file. In both cases, WEXISTATUS(pstat) yields a 6 digit integer (in the case of WIFSIGNALED, the signal is either 96 or 120 which both mean nothing to me) that isn't of any use to me as I'd like to gather the argument to exit of the child in order to decide whether it did it's job and nothing else. What am I doing wrong? If I do a simple fork() + exec() sequence without pipe magic, I always get to see WIFEXITED=true and the correct status... Best regards, Gabriel  -----BEGIN PGP SIGNATURE----- Version: PGP 6.5i iQEVAwUBO1mmq8Za2WpymlDxAQES7wf/bjZrhzCQe5qEQ07Ocq92aQ66DNaUrGO9 9Kc26STrmh0dwK1es29u6wR1RFKrpswzfNP/AaRpj9fLpT8Mj3fGrJAwHLmygIjR Z/hxnIXtCBJMQNWyHHYPmTYea1ogztLSd4fOL+lTiWm1hNWJENz8bnOon+tm5zvk WrDsm+nZ1zwVVa9QlZqraSLDC6+OmizcFTuC6xJCnxKSkpqitW0o/CKr9xa1YQ3f HCh+FLIsyCGhaoW8qjxbokUtNnePVc60cXhPS/bKO0bdhhTSjBIUA3x8TpaNlz4H bb/zjGl8H9zVXSCAAky0V8/tC9XxOtZXr+WWVl3efMeOJFIQOGha2w== =iR4c -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message