this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Linux signalfd() usage

+20 -2
+20 -2
src/kernel/emulation/linux/ext/signalfd.c
··· 1 + #include "../fcntl/fcntl.h" 1 2 #include "./sys/signalfd.h" 2 3 #include "../errno.h" 3 4 #include "../base.h" ··· 9 10 VISIBLE 10 11 int signalfd (int __fd, const sigset_t *__mask, int __flags) 11 12 { 12 - int rv; 13 + int rv, linux_flags = 0; 13 14 linux_sigset_t linux_mask; 14 15 15 16 sigset_bsd_to_linux(__mask, &linux_mask); 16 17 17 - rv = LINUX_SYSCALL(__NR_signalfd, linux_mask, __flags); 18 + if (__flags & O_CLOEXEC) 19 + linux_flags |= 02000000; 20 + if (__flags & O_NONBLOCK) 21 + linux_flags |= 04000; 22 + 23 + #ifdef __NR_signalfd4 24 + rv = LINUX_SYSCALL(__NR_signalfd4, __fd, &linux_mask, 8, linux_flags); 25 + #else 26 + rv = LINUX_SYSCALL(__NR_signalfd, __fd, &linux_mask, 8); 27 + // handle flags 28 + if (rv >= 0) 29 + { 30 + if (__flags & O_CLOEXEC) 31 + sys_fcntl(rv, F_SETFD, BSD_FD_CLOEXEC); 32 + if (__flags & O_NONBLOCK) 33 + sys_fcntl(rv, F_SETFL, BSD_O_NONBLOCK); 34 + } 35 + #endif 18 36 if (rv < 0) 19 37 { 20 38 cerror(errno_linux_to_bsd(rv));