(main): Don't assume fopen returns stdout after closing
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Apr 2005 20:10:00 +0000 (20:10 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 11 Apr 2005 20:10:00 +0000 (20:10 +0000)
stdout.  Use freopen instead.

src/ptx.c

index 6e5d912be333dc171d9299fd6198abda76dfbdbf..a5f7c1aeb14599efef2c8ccd7371354297cd54e0 100644 (file)
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -2154,9 +2154,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"),
 
       if (optind < argc)
        {
-         /* FIXME: don't fclose here? */
-         fclose (stdout);
-         if (fopen (argv[optind], "w") == NULL)
+         if (! freopen (argv[optind], "w", stdout))
            error (EXIT_FAILURE, errno, "%s", argv[optind]);
          optind++;
        }