This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 17 Jun 2016 12:12, Pedro Alves wrote:
> On 06/17/2016 06:29 AM, Mike Frysinger wrote:
>
> > + /* Bind stderr to stdout so that tests don't have to worry about which
> > + one to use, and whether funcs they use (e.g. assert) will go to the
> > + wrong place. */
> > + fclose (stderr);
> > + if (dup2 (STDOUT_FILENO, STDERR_FILENO) == -1)
> > + {
> > + printf ("binding stderr to stdout failed: %m\n");
> > + exit (1);
> > + }
> > + stderr = fdopen (STDERR_FILENO, "w");
> > + /* Since stderr always starts out unbuffered, recreate that here. */
> > + setbuf (stderr, NULL);
>
> Why do you need to fclose/fdopen stderr at all?
> Just the "dup2 (STDOUT_FILENO, STDERR_FILENO)" should be enough.
we discussed it here where i asked for docs:
https://sourceware.org/ml/libc-alpha/2016-06/msg00636.html
> Note that that's what
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html
>
> suggests in its example section:
>
> ~~~~~~~~~~~~~~~~~~~~~
> Redirecting Error Messages
>
> The following example redirects messages from stderr to stdout.
>
> #include <unistd.h>
> ...
> dup2(1, 2);
> ...
> ~~~~~~~~~~~~~~~~~~~~~
that only guarantees the fd level. where do we guarantee the stdio level ?
-mike
Attachment:
signature.asc
Description: Digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |