[uClibc]Re: stderr problem
cfowler
cfowler at outpostsentinel.com
Wed Aug 28 12:36:58 UTC 2002
One option could be to open /proc/self/fd/2
If it still exists. Or to reopen the tty and
dup it to STDERR.
Maybe this should work
fd = open(ttyname(), O_WRONLY);
dup2(fd, 2);
close(fd);
On Wed, 2002-08-28 at 08:24, Miles Bader wrote:
> On Wed, Aug 28, 2002 at 12:53:12PM +0200, dag4004 wrote:
> > >So after you call `freopen', f and stderr are the same stream; if you
> > >close f, then you've closed stderr too.
> >
> > Ok, but after closing the file how could i restor stderr for normal purpose?
>
> I'm not sure that you can, in a clean way.
>
> I suppose you could do something like:
>
> (1) Before you do the `freopen', do `int saved_fd = dup (2);'
>
> (2) After you've closed f, do `stderr = fdopen (saved_fd, "w");'
>
> [I think this is legal in glibc at least; not sure about uClibc's stdio)]
>
> -Miles
> --
> P.S. All information contained in the above letter is false,
> for reasons of military security.
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://uclibc.org/mailman/listinfo/uclibc
>
>
More information about the uClibc
mailing list