Dmitry V. Levin | 2307d5c | 2015-08-03 09:12:26 +0000 | [diff] [blame] | 1 | #include "defs.h" |
Dmitry V. Levin | 30ac062 | 2015-08-03 09:47:25 +0000 | [diff] [blame] | 2 | #include <fcntl.h> |
| 3 | #ifdef HAVE_SYS_SIGNALFD_H |
| 4 | # include <sys/signalfd.h> |
| 5 | #endif |
| 6 | |
| 7 | #include "xlat/sfd_flags.h" |
Dmitry V. Levin | 2307d5c | 2015-08-03 09:12:26 +0000 | [diff] [blame] | 8 | |
| 9 | static int |
| 10 | do_signalfd(struct tcb *tcp, int flags_arg) |
| 11 | { |
| 12 | /* NB: kernel requires arg[2] == NSIG / 8 */ |
| 13 | printfd(tcp, tcp->u_arg[0]); |
| 14 | tprints(", "); |
| 15 | print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 16 | tprintf(", %lu", tcp->u_arg[2]); |
| 17 | if (flags_arg >= 0) { |
| 18 | tprints(", "); |
Dmitry V. Levin | 30ac062 | 2015-08-03 09:47:25 +0000 | [diff] [blame] | 19 | printflags(sfd_flags, tcp->u_arg[flags_arg], "SFD_???"); |
Dmitry V. Levin | 2307d5c | 2015-08-03 09:12:26 +0000 | [diff] [blame] | 20 | } |
| 21 | |
Dmitry V. Levin | 9e8a84f | 2015-08-03 09:14:28 +0000 | [diff] [blame] | 22 | return RVAL_DECODED | RVAL_FD; |
Dmitry V. Levin | 2307d5c | 2015-08-03 09:12:26 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | SYS_FUNC(signalfd) |
| 26 | { |
| 27 | return do_signalfd(tcp, -1); |
| 28 | } |
| 29 | |
| 30 | SYS_FUNC(signalfd4) |
| 31 | { |
| 32 | return do_signalfd(tcp, 3); |
| 33 | } |