WSSetSignalHandler (C Function)

int WSSetSignalHandler(WSENV env,int s,void *sa)

installs the Unix signal handler detailed in the object sa for signal s in the WSTP library signal-handling mechanism.


  • WSSetSignalHandler() does nothing on Microsoft Windows.
  • sa is a pointer to a Unix sigaction struct. See the header file signal.h on most Unix and Unix-like systems for details regarding the sigaction structure.
  • WSSetSignalHandler() returns WSEOK if no error occurs and one of the other error codes as listed in wstp.h in the event of an error.
  • WSSetSignalHandler() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include <signal.h>
#include "wstp.h"

void app_signal_handler(int signum)
    /* ... */

/* set a signal handler in the WSTP environment */

void f(WSENV ep)
    struct sigaction sa;
    int err;

    sa.sa_handler = (void (*)(int))app_signal_handler;
    sa.sa_flags = 0;

    /* install app_signal_handler for SIGHUP */
    err = WSSetSignalHandler(ep, SIGHUP, (void *)&sa);
    if(err != WSEOK)
        { /* unable to set the signal handler in ep */ }