MLSetSignalHandler (C Function)
MLSetSignalHandler has been replaced by WSSetSignalHandler.
int MLSetSignalHandler(MLENV env,int s,void *sa)
installs the Unix signal handler detailed in the object sa for signal s in the MathLink library signal-handling mechanism.
Details
- MLSetSignalHandler() 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.
- MLSetSignalHandler() returns MLEOK if no error occurs and one of the other error codes as listed in mathlink.h in the event of an error.
- MLSetSignalHandler() is declared in the MathLink header file mathlink.h.
Examples
Basic Examples (1)
#include <signal.h>
#include "mathlink.h"
void app_signal_handler(int signum)
{
/* ... */
}
/* set a signal handler in the MathLink environment */
void f(MLENV 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 = MLSetSignalHandler(ep, SIGHUP, (void *)&sa);
if(err != MLEOK)
{ /* unable to set the signal handler in ep */ }
}