Date: Thu, 8 Oct 1998 12:07:57 -0400 (EDT) Message-Id: <199810081607.MAA15331@indy.delorie.com> From: DJ Delorie To: eliz AT is DOT elta DOT co DOT il CC: djgpp-workers AT delorie DOT com In-reply-to: (message from Eli Zaretskii on Thu, 8 Oct 1998 18:59:43 +0300 (IDT)) Subject: Re: Bug in popen Reply-To: djgpp-workers AT delorie DOT com > I think this is a bug. Man pages on all Unix boxes that I could access > explicitly say that failure to fork causes NULL to be returned. DJ, is > that what Posix says as well? POSIX assumes you're using a command interpreter to run the programs, which we usually don't do. In the case where the command interpreter fails to run the given program, pclose() should return an error. popen() returns an error if the pipe cannot be created or the fork fails; other errors are deferred until pclose(). We don't fork(), so how could we return that error? However, the exact wording is "The popen() function shall return a NULL pointer if the pipe or subprocess cannot be created. Otherwise, it shall return a stream pointer as described above." This could be interpreted as letting our popen() return NULL if the program to run doesn't exist.