Mail Archives: djgpp/1996/10/23/22:39:27
In article <Pine DOT SUN DOT 3 DOT 91 DOT 961023094058 DOT 6813R-100000 AT is>, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> writes:
|>
|>On Mon, 21 Oct 1996, Juanjo Erauskin wrote:
|>
|>> "A stream opened by popen should be closed by pclose, which waits
|>> for the associated process to terminate and returns the exit status of
|>> the command. "
|>>
|>> DJGPP pclose() function doesn't return exit status. Return 0 if
|>> pclose is OK or return -1 if pclose doesn't terminate good.
|>
|>The question is: what does POSIX say about `pclose'? DJ?
My copy of the POSIX spec has gone walkabout, but looking at
the man pages of 3 POSIX-compliant systems here they all agree
that what popen actually returns is the status that would be
returned by "waitpid" on the child. This is actually an encoded
version of the return status, and there are a set of defined macros
that extract various fields from it. That said, I don't believe POSIX
says anything about popen or pclose - they aren't part of its world.
|>
|>The diff you posted is incomplete, I think. On MSDOS, when you call
|>`popen' to *read* from the pipe, the command is called by `popen', and
|>`pclose' just closes and deletes the temporary file used as the ``pipe''.
|>So in that case, the exit status should be saved by `popen' to be returned
|>later by `pclose'.
|>
I think you are right. The diff Juanjo posted was to popen:
|>> if ((retval = system (l1->command)) == EOF)
but it's not clear what's happening to retval. However, it is the
right status, since system() is defined to return the same wstat-encoded
return status as waitpid (and pclose). Whether or not the thing
is meaningful depends on what system() actually does return under
djgpp, and I don't have my machine to hand to check that with the
docs.
------------------------------------------------------------------------------
Kevin Ashley K DOT Ashley AT Ulcc DOT ac DOT uk
Development Manager http://www.ulcc.ac.uk/staff/Kevin+Ashley
University of London Computer Centre. ...ukc!ncdlab!K.Ashley
This is not a signature
- Raw text -