[libiberty] support piping stderr

Ian Lance Taylor iant@google.com
Wed Jan 31 15:38:00 GMT 2007


Vladimir Prus <vladimir@codesourcery.com> writes:

> +  if (errname != NULL && (flags & PEX_STDERR_TO_PIPE))

Write the test as
    (flags & PEX_STDERR_TO_PIPE) != 0
as in other parts of the file.


Note that PEX_STDERR_TO_PIPE will only work on Unix and Windows.
This needs to be mentioned in the comments in libiberty.h.

In principle, given that we are restricted to Unix and Windows, there
is no reason not to support PEX_STDERR_TO_PIPE for any process in the
pipeline.  The children field of pex_obj could be promoted to an array
of struct to record the stderr pipe descriptor number.  One could call
something like pex_get_status to get all the file descriptors.  But I
don't know if this facility would be useful.


> +      if (flags & PEX_STDERR_TO_PIPE)

This should also be written as
    ((flags & PEX_STDERR_TO_PIPE) != 0)
If we retain the restriction that you can only use this on the last
program, then you should also check PEX_LAST here and give an error if
it is not set.


> +	  if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_OUTPUT) != 0) < 0)

You can't use PEX_BINARY_OUTPUT to decide whether stderr is in binary
mode.  For the programs invoked by pex in a pipeline, it is natural
for standard output to be binary while stderr is in text mode.  You
need to introduce PEX_BINARY_ERROR.  And then it should be used in the
existing errname == NULL case.


You need to update the documentation in libiberty/pexecute.txh.


Please fix and resend.

Thanks.

Ian



More information about the Gcc-patches mailing list