1570af302Sopenharmony_ci#include <signal.h> 2570af302Sopenharmony_ci#include <unsupported_api.h> 3570af302Sopenharmony_ci#ifndef __LITEOS__ 4570af302Sopenharmony_ci#include <errno.h> 5570af302Sopenharmony_ci 6570af302Sopenharmony_ciextern int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old); 7570af302Sopenharmony_ci#endif 8570af302Sopenharmony_ciint siginterrupt(int sig, int flag) 9570af302Sopenharmony_ci{ 10570af302Sopenharmony_ci#ifndef __LITEOS__ 11570af302Sopenharmony_ci if (sig - 32U < 3 || sig - 1U >= _NSIG-1) { 12570af302Sopenharmony_ci errno = EINVAL; 13570af302Sopenharmony_ci return -1; 14570af302Sopenharmony_ci } 15570af302Sopenharmony_ci struct sigaction sa; 16570af302Sopenharmony_ci 17570af302Sopenharmony_ci __libc_sigaction(sig, 0, &sa); 18570af302Sopenharmony_ci if (flag) sa.sa_flags &= ~SA_RESTART; 19570af302Sopenharmony_ci else sa.sa_flags |= SA_RESTART; 20570af302Sopenharmony_ci 21570af302Sopenharmony_ci return __libc_sigaction(sig, &sa, 0); 22570af302Sopenharmony_ci#else 23570af302Sopenharmony_ci UNSUPPORTED_API_VOID(LITEOS_A); 24570af302Sopenharmony_ci struct sigaction sa; 25570af302Sopenharmony_ci 26570af302Sopenharmony_ci sigaction(sig, 0, &sa); 27570af302Sopenharmony_ci if (flag) sa.sa_flags &= ~SA_RESTART; 28570af302Sopenharmony_ci else sa.sa_flags |= SA_RESTART; 29570af302Sopenharmony_ci 30570af302Sopenharmony_ci return sigaction(sig, &sa, 0); 31570af302Sopenharmony_ci#endif 32570af302Sopenharmony_ci} 33