rework langinfo code for ABI compat and for use by time code
[musl] / src / linux / signalfd.c
1 #include <sys/signalfd.h>
2 #include <signal.h>
3 #include <errno.h>
4 #include <fcntl.h>
5 #include "syscall.h"
6
7 int signalfd(int fd, const sigset_t *sigs, int flags)
8 {
9         int ret = __syscall(SYS_signalfd4, fd, sigs, _NSIG/8, flags);
10         if (ret != -ENOSYS) return __syscall_ret(ret);
11         ret = __syscall(SYS_signalfd, fd, sigs, _NSIG/8);
12         if (ret >= 0) {
13                 if (flags & SFD_CLOEXEC)
14                         __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
15                 if (flags & SFD_NONBLOCK)
16                         __syscall(SYS_fcntl, ret, F_SETFL, O_NONBLOCK);
17         }
18         return __syscall_ret(ret);
19 }