Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 1999 00:30:05 -0400 (EDT)
From:      Mikhail Teterin <mi@kot.ne.mediaone.net>
To:        questions@freebsd.org
Subject:   result of pclose
Message-ID:  <199907140430.AAA30964@kot.ne.mediaone.net>

next in thread | raw e-mail | index | archive | help
The following simple program:

	#include <stdio.h>
	main() {
		FILE *pipe;
		int code;

		pipe = popen("/usr/bin/false", "w");
		code = pclose(pipe);
		printf("/usr/bin/false's result was %d\n", code);

		pipe = popen("/usr/bin/true", "w");
		code = pclose(pipe);
		printf("/usr/bin/true's result was %d\n", code);
	}

Produces:
	/usr/bin/false's result was 256
	/usr/bin/true's result was 0

I checked and rechecked -- false(1) returns 1

	mi@guest:/tmp (1099) false
	mi@guest:/tmp (1100) echo $status
	1

According to pclose(3), its result must be the exit code of the process.
Is this a bug, or do I misunderstand the manual? Thanks!

	-mi


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?199907140430.AAA30964>