summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/timerfd.c5
-rw-r--r--include/linux/timerfd.h5
2 files changed, 8 insertions, 2 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 77c2bc92cbe..c6ef5e33cb3 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -184,7 +184,7 @@ asmlinkage long sys_timerfd_create(int clockid, int flags)
int ufd;
struct timerfd_ctx *ctx;
- if (flags)
+ if (flags & ~TFD_CLOEXEC)
return -EINVAL;
if (clockid != CLOCK_MONOTONIC &&
clockid != CLOCK_REALTIME)
@@ -198,7 +198,8 @@ asmlinkage long sys_timerfd_create(int clockid, int flags)
ctx->clockid = clockid;
hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
- ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, 0);
+ ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
+ flags & O_CLOEXEC);
if (ufd < 0)
kfree(ctx);
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index cf2b10d7573..96ed97dff00 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -8,9 +8,14 @@
#ifndef _LINUX_TIMERFD_H
#define _LINUX_TIMERFD_H
+/* For O_CLOEXEC */
+#include <linux/fcntl.h>
+/* Flags for timerfd_settime. */
#define TFD_TIMER_ABSTIME (1 << 0)
+/* Flags for timerfd_create. */
+#define TFD_CLOEXEC O_CLOEXEC
#endif /* _LINUX_TIMERFD_H */