2 * Check decoding of ERESTARTSYS error code.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <sys/socket.h>
30 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
31 perror_msg_and_skip("socketpair");
33 const struct sigaction act = {
34 .sa_handler = handler,
35 .sa_flags = SA_RESTART
37 if (sigaction(SIGALRM, &act, NULL))
38 perror_msg_and_fail("sigaction");
42 sigaddset(&mask, SIGALRM);
43 if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
44 perror_msg_and_fail("sigprocmask");
46 const struct itimerval itv = { .it_value.tv_usec = 123456 };
47 if (setitimer(ITIMER_REAL, &itv, NULL))
48 perror_msg_and_fail("setitimer");
50 if (recvfrom(sv[0], &sv[1], sizeof(sv[1]), 0, NULL, NULL))
51 perror_msg_and_fail("recvfrom");
53 printf("recvfrom(%d, %p, %d, 0, NULL, NULL) = ? ERESTARTSYS"
54 " (To be restarted if SA_RESTART is set)\n",
55 sv[0], &sv[1], (int) sizeof(sv[1]));
56 printf("recvfrom(%d, \"\", %d, 0, NULL, NULL) = 0\n",
57 sv[0], (int) sizeof(sv[1]));
59 puts("+++ exited with 0 +++");