diff options
Diffstat (limited to 'man2/pidfd_open.2')
-rw-r--r-- | man2/pidfd_open.2 | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/man2/pidfd_open.2 b/man2/pidfd_open.2 index 701abd419..a1eac4cf3 100644 --- a/man2/pidfd_open.2 +++ b/man2/pidfd_open.2 @@ -215,42 +215,42 @@ event. #include <stdlib.h> #include <sys/syscall.h> #include <unistd.h> - +\& static int pidfd_open(pid_t pid, unsigned int flags) { return syscall(SYS_pidfd_open, pid, flags); } - +\& int main(int argc, char *argv[]) { int pidfd, ready; struct pollfd pollfd; - +\& if (argc != 2) { fprintf(stderr, "Usage: %s <pid>\en", argv[0]); exit(EXIT_SUCCESS); } - +\& pidfd = pidfd_open(atoi(argv[1]), 0); if (pidfd == \-1) { perror("pidfd_open"); exit(EXIT_FAILURE); } - +\& pollfd.fd = pidfd; pollfd.events = POLLIN; - +\& ready = poll(&pollfd, 1, \-1); if (ready == \-1) { perror("poll"); exit(EXIT_FAILURE); } - +\& printf("Events (%#x): POLLIN is %sset\en", pollfd.revents, (pollfd.revents & POLLIN) ? "" : "not "); - +\& close(pidfd); exit(EXIT_SUCCESS); } |