28 #if defined (HAVE_CONFIG_H) 32 #include <sys/types.h> 38 #if defined (__WIN32__) && ! defined (__CYGWIN__) 49 #if defined (HAVE_KILL) 53 octave_unused_parameter (pid);
54 octave_unused_parameter (
signum);
69 #if defined (HAVE_KILL) 83 if (!
strcmp (signame,
"SIGINT"))
90 else if (!
strcmp (signame,
"SIGBREAK"))
92 #if defined (SIGBREAK) 97 else if (!
strcmp (signame,
"SIGABRT"))
104 else if (!
strcmp (signame,
"SIGALRM"))
106 #if defined (SIGALRM) 111 else if (!
strcmp (signame,
"SIGBUS"))
118 else if (!
strcmp (signame,
"SIGCHLD"))
120 #if defined (SIGCHLD) 125 else if (!
strcmp (signame,
"SIGCLD"))
132 else if (!
strcmp (signame,
"SIGCONT"))
134 #if defined (SIGCONT) 139 else if (!
strcmp (signame,
"SIGEMT"))
146 else if (!
strcmp (signame,
"SIGFPE"))
153 else if (!
strcmp (signame,
"SIGHUP"))
160 else if (!
strcmp (signame,
"SIGILL"))
167 else if (!
strcmp (signame,
"SIGINFO"))
169 #if defined (SIGINFO) 174 else if (!
strcmp (signame,
"SIGINT"))
181 else if (!
strcmp (signame,
"SIGIOT"))
188 else if (!
strcmp (signame,
"SIGLOST"))
190 #if defined (SIGLOST) 195 else if (!
strcmp (signame,
"SIGPIPE"))
197 #if defined (SIGPIPE) 202 else if (!
strcmp (signame,
"SIGPOLL"))
204 #if defined (SIGPOLL) 209 else if (!
strcmp (signame,
"SIGPROF"))
211 #if defined (SIGPROF) 216 else if (!
strcmp (signame,
"SIGPWR"))
223 else if (!
strcmp (signame,
"SIGQUIT"))
225 #if defined (SIGQUIT) 230 else if (!
strcmp (signame,
"SIGSEGV"))
232 #if defined (SIGSEGV) 237 else if (!
strcmp (signame,
"SIGSTOP"))
239 #if defined (SIGSTOP) 244 else if (!
strcmp (signame,
"SIGSYS"))
251 else if (!
strcmp (signame,
"SIGTERM"))
253 #if defined (SIGTERM) 258 else if (!
strcmp (signame,
"SIGTRAP"))
260 #if defined (SIGTRAP) 265 else if (!
strcmp (signame,
"SIGTSTP"))
267 #if defined (SIGTSTP) 272 else if (!
strcmp (signame,
"SIGTTIN"))
274 #if defined (SIGTTIN) 279 else if (!
strcmp (signame,
"SIGTTOU"))
281 #if defined (SIGTTOU) 286 else if (!
strcmp (signame,
"SIGURG"))
293 else if (!
strcmp (signame,
"SIGUSR1"))
295 #if defined (SIGUSR1) 300 else if (!
strcmp (signame,
"SIGUSR2"))
302 #if defined (SIGUSR2) 307 else if (!
strcmp (signame,
"SIGVTALRM"))
309 #if defined (SIGVTALRM) 314 else if (!
strcmp (signame,
"SIGIO"))
321 else if (!
strcmp (signame,
"SIGWINCH"))
323 #if defined (SIGWINCH) 328 else if (!
strcmp (signame,
"SIGXCPU"))
330 #if defined (SIGXCPU) 335 else if (!
strcmp (signame,
"SIGXFSZ"))
337 #if defined (SIGXFSZ) 348 bool restart_syscalls)
350 struct sigaction act, oact;
352 act.sa_handler = handler;
355 #if defined (SIGALRM) 358 # if defined (SA_INTERRUPT) 359 act.sa_flags |= SA_INTERRUPT;
363 #if defined (SA_RESTART) 364 # if defined (SIGALRM) 368 if (restart_syscalls)
369 act.sa_flags |= SA_RESTART;
372 sigemptyset (&act.sa_mask);
373 sigemptyset (&oact.sa_mask);
375 sigaction (sig, &act, &oact);
377 return oact.sa_handler;
383 bool restart_syscalls)
419 #if defined (SIGCHLD) || defined (SIGCLD) 425 sigemptyset (&(
context->ovar));
426 sigemptyset (&(
context->nvar));
427 #if defined (SIGCHLD) 428 sigaddset (&(
context->nvar), SIGCHLD);
431 sigaddset (&(
context->nvar), SIGCLD);
452 sigprocmask (SIG_SETMASK, &(
context->ovar), 0);
461 #if ! defined (__WIN32__) || defined (__CYGWIN__) 470 sigset_t signal_mask;
472 sigemptyset (&signal_mask);
474 sigaddset (&signal_mask, sig);
476 pthread_sigmask (how, &signal_mask, 0);
480 octave_unused_parameter (how);
481 octave_unused_parameter (sig);
491 #if defined (SIGBREAK) 501 #if defined (SIGBREAK) 552 return malloc (
sizeof (sigset_t));
564 sigprocmask (0, 0, mask);
570 sigprocmask (SIG_SETMASK, (sigset_t *) mask, 0);
573 #if ! defined (__WIN32__) 574 static const sigset_t *
578 static sigset_t sigmask;
582 sigemptyset (&sigmask);
590 sigaddset (&sigmask, SIGINT);
593 #if defined (SIGBREAK) 594 sigaddset (&sigmask, SIGBREAK);
600 sigaddset (&sigmask, SIGHUP);
603 #if defined (SIGQUIT) 604 sigaddset (&sigmask, SIGQUIT);
607 #if defined (SIGTERM) 608 sigaddset (&sigmask, SIGTERM);
613 #if defined (SIGALRM) 614 sigaddset (&sigmask, SIGALRM);
617 #if defined (SIGVTALRM) 618 sigaddset (&sigmask, SIGVTALRM);
623 #if defined (SIGLOST) 624 sigaddset (&sigmask, SIGLOST);
627 #if defined (SIGPIPE) 628 sigaddset (&sigmask, SIGPIPE);
633 #if defined (SIGCHLD) 634 sigaddset (&sigmask, SIGCHLD);
638 sigaddset (&sigmask, SIGCLD);
643 #if defined (SIGXCPU) 644 sigaddset (&sigmask, SIGXCPU);
647 #if defined (SIGXFSZ) 648 sigaddset (&sigmask, SIGXFSZ);
661 #if ! defined (__WIN32__) || defined (__CYGWIN__) 669 #if ! defined (__WIN32__) || defined (__CYGWIN__) 680 #if ! defined (__WIN32__) 694 if (sigwait (async_signals, &sig_caught))
701 (*handler) (sig_caught);
709 #if ! defined (__WIN32__) 710 pthread_t sighandler_thread_id;
712 if (pthread_create (&sighandler_thread_id, 0,
signal_watcher, handler))
720 octave_unused_parameter (handler);
724 #if ! defined (__WIN32__) 731 for (sig = 1; sig < NSIG; sig++)
733 if (sigismember (sigset, sig))
736 fprintf (
of,
"%ld: %s%d (%s)\n", (
long int) pthread_self (),
737 prefix, sig, strsignal (sig));
742 fprintf (
of,
"%ld: %s<empty signal set>\n", (
long int) pthread_self (),
752 fprintf (
of,
"%s", msg);
754 if (pthread_sigmask (SIG_BLOCK, NULL, &sigmask) == -1)
766 #if ! defined (__WIN32__) 768 msg =
"signal mask\n";
772 octave_unused_parameter (msg);
774 fputs (
"no signal mask on Windows systems\n", stderr);
static void print_sigset(FILE *of, const char *prefix, const sigset_t *sigset)
static void block_or_unblock_signal(int how, int sig)
int kill(pid_t pid, int sig)
int octave_kill_wrapper(pid_t pid, int signum)
octave_sig_handler * octave_set_default_signal_handler(int sig)
static const sigset_t * octave_async_signals(void)
void octave_restore_signal_mask(void)
octave_sig_handler * octave_set_signal_handler_internal(int sig, octave_sig_handler *handler, bool restart_syscalls)
void * octave_block_child(void)
static llvm::LLVMContext & context
void octave_sig_handler(int)
void octave_block_signal_by_name(const char *signame)
static int print_sigmask(FILE *of, const char *msg)
fputs(in, "these\re\ome\trings\)
void octave_unblock_child(void *context_arg)
void octave_create_interrupt_watcher_thread(octave_sig_handler *handler)
void octave_free_signal_mask(void *mask)
bool strcmp(const T &str_a, const T &str_b)
True if strings are the same.
void octave_block_interrupt_signal(void)
void octave_set_signal_mask(void *mask)
void octave_save_signal_mask(void)
void octave_show_sigmask(const char *msg)
int octave_num_signals(void)
void * octave_alloc_signal_mask(void)
static void block_or_unblock_signal_by_name(int how, const char *signame)
bool octave_have_kill(void)
void octave_unblock_async_signals(void)
void octave_get_signal_mask(void *mask)
int octave_raise_wrapper(int signum)
static sigset_t octave_signal_mask
octave_sig_handler * octave_set_default_signal_handler_by_name(const char *signame)
void octave_block_async_signals(void)
void octave_unblock_interrupt_signal(void)
defaults to zero A value of zero computes the digamma a value of
bool octave_get_sig_number(const char *signame, int *signum)
octave_sig_handler * octave_set_signal_handler_by_name(const char *signame, octave_sig_handler *handler, bool restart_syscalls)
static void * signal_watcher(void *arg)
void octave_unblock_signal_by_name(const char *signame)
char * octave_strsignal_wrapper(int signum)