blob: f99b7228027f79be87a48150b14d5ddb08acc3db [file] [log] [blame]
Dmitry V. Levind9fb4502015-07-30 19:46:11 +00001#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <poll.h>
6#include <signal.h>
7#include <unistd.h>
8
9static int
10test1(void)
11{
12 sigset_t mask;
13 const struct timespec timeout = { .tv_sec = 42, .tv_nsec = 999999999 };
14 struct pollfd fds[] = {
15 { .fd = 0, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND },
16 { .fd = 1, .events = POLLOUT | POLLWRNORM | POLLWRBAND },
17 { .fd = 3, .events = POLLIN | POLLPRI },
18 { .fd = 4, .events = POLLOUT }
19 };
20
21 sigemptyset(&mask);
22 sigaddset(&mask, SIGUSR2);
23 sigaddset(&mask, SIGCHLD);
24
25 return ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask) == 2 ? 0 : 77;
26}
27
28static int
29test2(void)
30{
31 sigset_t mask;
32 const struct timespec timeout = { .tv_sec = 0, .tv_nsec = 999 };
33 struct pollfd fds[] = {
34 { .fd = 1, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND },
35 { .fd = 0, .events = POLLOUT | POLLWRNORM | POLLWRBAND }
36 };
37
38 sigfillset(&mask);
Dmitry V. Levin0c0453a2015-08-01 08:55:32 +000039 sigdelset(&mask, SIGHUP);
Dmitry V. Levind9fb4502015-07-30 19:46:11 +000040 sigdelset(&mask, SIGKILL);
41 sigdelset(&mask, SIGSTOP);
42
43 return ppoll(fds, sizeof(fds) / sizeof(*fds), &timeout, &mask) == 0 ? 0 : 77;
44}
45
46int
47main(void)
48{
49 int rc;
50 int fds[2];
51
52 (void) close(0);
53 (void) close(1);
54 (void) close(3);
55 (void) close(4);
56 if (pipe(fds) || pipe(fds))
57 return 77;
58
59
60 if ((rc = test1()))
61 return rc;
62
63 if ((rc = test2()))
64 return rc;
65
66 return ppoll(NULL, 42, NULL, NULL) < 0 ? 0 : 77;
67}