blob: cab48005191260fdfd87ec7274a32abac9bcd052 [file] [log] [blame]
sewardjcbdddcf2005-03-10 23:23:45 +00001#include <time.h>
2#include <unistd.h>
3#include <stdio.h>
4#include <errno.h>
5#include <signal.h>
6
7#include "../memcheck.h"
8
9/* Check that a syscall's POST function gets called if it completes
10 due to being interrupted. nanosleep is used here, because it
11 writes a result even if it fails. wait*() could also be used,
12 because they successully complete if interrupted by SIGCHLD.
13 */
14static void handler(int s)
15{
16}
17
18int main()
19{
20 struct timespec req, rem;
21 int ret;
22
23 req.tv_sec = 2;
24 req.tv_nsec = 0;
25
26 signal(SIGALRM, handler);
27
28 alarm(1);
29 ret = nanosleep(&req, &rem);
30
31 if (ret != -1 || errno != EINTR) {
32 printf("FAILED: expected nanosleep to be interrupted\n");
33 } else {
njndbf7ca72006-03-31 11:57:59 +000034 VALGRIND_CHECK_VALUE_IS_DEFINED(rem);
35 printf("PASSED\n"); /* assuming CHECK_VALUE_IS_DEFINED doesn't print anything */
sewardjcbdddcf2005-03-10 23:23:45 +000036 }
37
38 return 0;
39}