1 #include <signal.h>
2 #include <unsupported_api.h>
3 #ifndef __LITEOS__
4 #include <errno.h>
5
6 extern int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old);
7 #endif
siginterrupt(int sig, int flag)8 int siginterrupt(int sig, int flag)
9 {
10 #ifndef __LITEOS__
11 if (sig - 32U < 3 || sig - 1U >= _NSIG-1) {
12 errno = EINVAL;
13 return -1;
14 }
15 struct sigaction sa;
16
17 __libc_sigaction(sig, 0, &sa);
18 if (flag) sa.sa_flags &= ~SA_RESTART;
19 else sa.sa_flags |= SA_RESTART;
20
21 return __libc_sigaction(sig, &sa, 0);
22 #else
23 UNSUPPORTED_API_VOID(LITEOS_A);
24 struct sigaction sa;
25
26 sigaction(sig, 0, &sa);
27 if (flag) sa.sa_flags &= ~SA_RESTART;
28 else sa.sa_flags |= SA_RESTART;
29
30 return sigaction(sig, &sa, 0);
31 #endif
32 }
33