Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / post-syscall.c
blob6655ab49852a0a7764a5f8b98806745cb709e3fc
1 #include <time.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <errno.h>
5 #include <signal.h>
7 #include "../memcheck.h"
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 successfully complete if interrupted by SIGCHLD.
14 static void handler(int s)
18 int main()
20 struct timespec req, rem;
21 int ret;
23 req.tv_sec = 2;
24 req.tv_nsec = 0;
26 signal(SIGALRM, handler);
28 alarm(1);
29 ret = nanosleep(&req, &rem);
31 if (ret != -1 || errno != EINTR) {
32 fprintf(stderr, "FAILED: expected nanosleep to be interrupted\n");
33 } else {
34 (void) VALGRIND_CHECK_VALUE_IS_DEFINED(rem);
35 fprintf(stderr, "PASSED\n"); /* assuming CHECK_VALUE_IS_DEFINED doesn't print anything */
38 return 0;