OpenersNotesSection(Spacer1)Details

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 (RefLink[wstp.h, paclet:ref/file/wstp.h]) in the event of an error.

WSSetSignalHandler() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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;
	sigemptyset(&sa.sa_mask);
	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 */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSSetSignalHandlerFromFunction(), paclet:ref/c/WSSetSignalHandlerFromFunction])  ▪  (NonWLLink[WSUnsetSignalHandler(), paclet:ref/c/WSUnsetSignalHandler])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}})}})