1 /*
2 * Check decoding of pause syscall.
3 *
4 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@strace.io>
5 * Copyright (c) 2016 Fei Jie <feij.fnst@cn.fujitsu.com>
6 * Copyright (c) 2016-2021 The strace developers.
7 * All rights reserved.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12 #include "tests.h"
13 #include "scno.h"
14
15 #ifdef __NR_pause
16
17 # include <errno.h>
18 # include <signal.h>
19 # include <stdio.h>
20 # include <sys/time.h>
21 # include <unistd.h>
22
23 static void
24 handler(int sig)
25 {
26 }
27
28 int
29 main(void)
30 {
31 const struct sigaction act = { .sa_handler = handler };
32 if (sigaction(SIGALRM, &act, NULL))
33 perror_msg_and_fail("sigaction");
34
35 sigset_t mask;
36 sigemptyset(&mask);
37 sigaddset(&mask, SIGALRM);
38 if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
39 perror_msg_and_fail("sigprocmask");
40
41 const struct itimerval itv = { .it_value.tv_usec = 123456 };
42 if (setitimer(ITIMER_REAL, &itv, NULL))
43 perror_msg_and_fail("setitimer");
44
45 syscall(__NR_pause);
46 if (errno == ENOSYS)
47 printf("pause() = -1 ENOSYS (%m)\n");
48 else
49 printf("pause() = ? ERESTARTNOHAND"
50 " (To be restarted if no handler)\n");
51
52 puts("+++ exited with 0 +++");
53 return 0;
54 }
55
56 #else
57
58 SKIP_MAIN_UNDEFINED("__NR_pause")
59
60 #endif