Date: Sat, 21 Jul 2001 18:58:31 +0200 From: Gabriel Ambuehl <gabriel_ambuehl@buz.ch> To: freebsd-questions@freebsd.org Subject: WEXITSTATUS yields strange results Message-ID: <64104717866.20010721185831@buz.ch>
next in thread | raw e-mail | index | archive | help
-----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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64104717866.20010721185831>