bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: freopen_safer


From: Eric Blake
Subject: Re: freopen_safer
Date: Thu, 05 Nov 2009 19:14:14 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 11/5/2009 10:43 AM:
> $ cat foo.c
> #include <stdio.h>
> int main()
> {
>   if (stderr != freopen("/dev/null","w",stderr))
>     return 5;
>   return fileno(stderr);
> }
> $ ./foo && echo $?
> 2
> $ ./foo <&- && echo $?
> 0
> $ ./foo >&- && echo $?
> 1

I typed this too fast.  To see the real answer:

$ ./foo; echo $?
2
$ ./foo <&-; echo $?
0
$ ./foo >&-; echo $?
1

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrzhnYACgkQ84KuGfSFAYD5qgCgmzIwCITOT4an9/YCpwdBtRn3
ZAoAn22OK8jIUQdbODRKA/Sny3NeK4X/
=WRpE
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]