time: fix build for toolchains without O_CLOEXEC
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Oct 2017 17:05:00 +0000 (19:05 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 27 Oct 2017 17:05:00 +0000 (19:05 +0200)
Based on patch by Eugene Rudoy <gene.devel@gmail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/time.c

index f4f8149d37be713f5ebc0b78c42f15f909d55e63..61f0787551b2a1eb45d14d9286db6b01a8c3ab47 100644 (file)
@@ -442,11 +442,16 @@ int time_main(int argc UNUSED_PARAM, char **argv)
                output_format = posix_format;
        output_fd = STDERR_FILENO;
        if (opt & OPT_o) {
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
                output_fd = xopen(output_filename,
                        (opt & OPT_a) /* append? */
                        ? (O_CREAT | O_WRONLY | O_CLOEXEC | O_APPEND)
                        : (O_CREAT | O_WRONLY | O_CLOEXEC | O_TRUNC)
                );
+               if (!O_CLOEXEC)
+                       close_on_exec_on(output_fd);
        }
 
        run_command(argv, &res);