This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[incremental] Patch: FYI: minor fileno cleanup
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 27 Mar 2008 09:22:51 -0600
- Subject: [incremental] Patch: FYI: minor fileno cleanup
- Reply-to: tromey at redhat dot com
I'm checking this in on the incremental-compiler branch.
I was using hard-coded file descriptor numbers instead of using fileno.
Tom
ChangeLog:
2008-03-27 Tom Tromey <tromey@redhat.com>
* server.c (server_start): Use fileno.
* toplev.c (server_callback): Use fileno.
Index: toplev.c
===================================================================
--- toplev.c (revision 133491)
+++ toplev.c (working copy)
@@ -2550,8 +2550,8 @@
/* The diagnostic machinery doesn't need this, but pex does. Also
GCC itself seems to write to stderr a lot ... */
- saved_stderr = dup (2);
- dup2 (fd, 2);
+ saved_stderr = dup (fileno (stderr));
+ dup2 (fd, fileno (stderr));
/* FIXME: make a new global_dc. Arrange to unlink assembler output
file on error. */
@@ -2588,7 +2588,7 @@
/* Make sure to close dup'd stderr (by overwriting it), so that
client will terminate properly. The server loop will take care
of the fd we were passed. */
- dup2 (saved_stderr, 2);
+ dup2 (saved_stderr, fileno (stderr));
close (saved_stderr);
return server_back_end_status && ! (errorcount || sorrycount);
Index: server.c
===================================================================
--- server.c (revision 132956)
+++ server.c (working copy)
@@ -164,8 +164,8 @@
close (fds[0]);
/* Don't need these any more -- but keep stderr while
debugging. */
- close (0);
- close (1);
+ close (fileno (stdin));
+ close (fileno (stdout));
execv (args[0], args);
error ("exec of server failed: %s", xstrerror (errno));
exit (FATAL_EXIT_CODE);