summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-07-21 16:55:40 -0400
committerPaul Smith <psmith@gnu.org>2013-07-21 16:56:00 -0400
commit72462ef1e181fc99837ba3077f9b5d192f16f6aa (patch)
tree6e9d45ebdedf7cbe1425b191901d0443db60ad06 /job.c
parentf80222c15b47d8926f6b430bc07c395d94f1dcc0 (diff)
downloadgunmake-72462ef1e181fc99837ba3077f9b5d192f16f6aa.tar.gz
Safety cleanups: ensure OUTFD is -1 when closed.
Diffstat (limited to 'job.c')
-rw-r--r--job.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/job.c b/job.c
index 68f1f26..0198905 100644
--- a/job.c
+++ b/job.c
@@ -687,7 +687,10 @@ assign_child_tempfiles (struct child *c)
error:
if (c->outfd >= 0)
- close (c->outfd);
+ {
+ close (c->outfd);
+ c->outfd = -1;
+ }
output_sync = 0;
}
@@ -700,8 +703,8 @@ pump_from_tmp (int from, FILE *to)
#ifdef WINDOWS32
int prev_mode;
- /* from_fd is opened by open_tmpfd, which does it in binary mode, so
- we need the mode of to_fd to match that. */
+ /* "from" is opened by open_tmpfd, which does it in binary mode, so
+ we need the mode of "to" to match that. */
prev_mode = _setmode (fileno (to), _O_BINARY);
#endif
@@ -721,7 +724,7 @@ pump_from_tmp (int from, FILE *to)
}
#ifdef WINDOWS32
- /* Switch to_fd back to its original mode, so that log messages by
+ /* Switch "to" back to its original mode, so that log messages by
Make have the same EOL format as without --output-sync. */
_setmode (fileno (to), prev_mode);
#endif
@@ -1753,7 +1756,7 @@ start_job_command (struct child *child)
#ifdef OUTPUT_SYNC
/* Divert child output if output_sync in use. Don't capture
recursive make output unless we are synchronizing "make" mode. */
- if (output_sync && sync_cmd)
+ if (sync_cmd)
{
int outfd = fileno (stdout);
int errfd = fileno (stderr);
@@ -1866,7 +1869,7 @@ start_job_command (struct child *child)
#ifdef OUTPUT_SYNC
/* Divert child output if output_sync in use. Don't capture
recursive make output unless we are synchronizing "make" mode. */
- if (output_sync && sync_cmd)
+ if (sync_cmd)
hPID = process_easy (argv, child->environment,
child->outfd, child->errfd);
else