This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


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.
  • 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.
#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;
    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 */ }