diff options
author | Wichert Akkerman <wichert@deephackmode.org> | 1999-02-19 00:21:36 +0000 |
---|---|---|
committer | Wichert Akkerman <wichert@deephackmode.org> | 1999-02-19 00:21:36 +0000 |
commit | 76baf7c9f6dd61a15524ad43c1b690c252cf5b7c (patch) | |
tree | c54cba971a5ca31d262dbf292fdae19601b7833d /test/procpollable.c | |
download | strace-76baf7c9f6dd61a15524ad43c1b690c252cf5b7c.tar.gz strace-76baf7c9f6dd61a15524ad43c1b690c252cf5b7c.tar.bz2 strace-76baf7c9f6dd61a15524ad43c1b690c252cf5b7c.tar.xz |
Initial revision
Diffstat (limited to 'test/procpollable.c')
-rw-r--r-- | test/procpollable.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/procpollable.c b/test/procpollable.c new file mode 100644 index 0000000..fc599b5 --- /dev/null +++ b/test/procpollable.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <signal.h> +#include <sys/procfs.h> +#include <sys/stropts.h> +#include <poll.h> +main() +{ + int pid; + char proc[32]; + FILE *pfp; + struct pollfd pfd; + + if ((pid = fork()) == 0) { + pause(); + exit(0); + } + sprintf(proc, "/proc/%d", pid); + if ((pfp = fopen(proc, "r+")) == NULL) + goto fail; + if (ioctl(fileno(pfp), PIOCSTOP, NULL) < 0) + goto fail; + pfd.fd = fileno(pfp); + pfd.events = POLLPRI; + if (poll(&pfd, 1, 0) < 0) + goto fail; + if (!(pfd.revents & POLLPRI)) + goto fail; + kill(pid, SIGKILL); + exit(0); +fail: + kill(pid, SIGKILL); + exit(1); +} |