+2013-06-28 Paul Smith <psmith@gnu.org>
+
+ * misc.c (set_append_mode): Set the O_APPEND flag on a file descriptor.
+ (open_tmpfd): Set append mode on the temporary file descriptor.
+ * main.c (main): Set append mode on stdout and stderr.
+ * makeint.h (set_append_mode): Declare it.
+
2013-06-22 Eli Zaretskii <eliz@gnu.org>
* build_w32.bat (LinkGCC): Prevent a comment from being displayed
* main.c (verify_flag): Global variable to determine whether to
verify the database or not.
(decode_debug_flags): If debug mode, enable verify_flag.
- (main): If MAKE_MAINTAINTER_MODE, enable verify_flag, otherwise not.
+ (main): If MAKE_MAINTAINER_MODE, enable verify_flag, otherwise not.
(die): Only verify the database if verify_flag is set.
* file.c (enter_file): Don't check caching unless verify_flag.
* makeint.h: Export verify_flag.
setlinebuf (stdout);
#endif /* setlinebuf missing. */
+ /* Configure stdout/stderr to be in append mode.
+ This keeps parallel jobs from losing output due to overlapping writes. */
+
+ set_append_mode (fileno (stdout));
+ set_append_mode (fileno (stderr));
+
/* Figure out where this program lives. */
if (argv[0] == 0)
void print_spaces (unsigned int);
char *find_percent (char *);
const char *find_percent_cached (const char **);
+void set_append_mode (int);
int open_tmpfd (void);
FILE *open_tmpfile (char **, const char *);
#include <stdarg.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#else
+# include <sys/file.h>
+#endif
/* Compare strings *S1 and *S2.
Return negative if the first is less, positive if it is greater,
#endif
\f
+/* Set a file descriptor to be in O_APPEND mode.
+ If it fails, just ignore it. */
+
+void
+set_append_mode (int fd)
+{
+#if defined(F_GETFL) && defined(F_SETFL) && defined(O_APPEND)
+ int flags = fcntl (fd, F_GETFL, 0);
+ if (flags >= 0)
+ fcntl (fd, F_SETFL, flags | O_APPEND);
+#endif
+}
+
/* Provide support for temporary files. */
#ifndef HAVE_STDLIB_H
fclose (tfile);
+ set_append_mode (fd);
+
return fd;
}