[PATCH v2 1/2] time applet: fix a build problem with kernel versions missing O_CLOEXEC symbol
Denys Vlasenko
vda.linux at googlemail.com
Fri Oct 27 17:07:16 UTC 2017
On Thu, Oct 19, 2017 at 12:05 AM, Eugene Rudoy <gene.devel at gmail.com> wrote:
> Kernel versions < 2.6.23 do not support/provide O_CLOEXEC symbol
> causing the time applet not to compile:
>
> time.c: In function 'time_main':
> time.c:445:28: error: 'O_CLOEXEC' undeclared (first use in this function)
> time.c:445:28: note: each undeclared identifier is reported only once for each function it appears in
This is not a kernel problem, it's toolchain.
I'm going with this:
+#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);
since it will not pessimize code for newer toolchains.
More information about the busybox
mailing list