en fr

Disponible uniquement en anglais

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Extension - Signals

This section describes functions which offer support for POSIX signals, i.e. a way for LME to be interrupted asynchronously from another process. They map directly to the kill and signal POSIX functions; therefore, they can interoperate with programs which call them directly.

These functions are available only on Posix systems, such as macOS.



Get the current process ID.


pid = getpid


getpid gives the ID of the current process.

See also



Send a signal to another process.


kill(pid, sig)


kill(pid) sends signal 2 (SIGINT) to process pid. kill(pid,sig) sends signal sig given as a number between 1 and 31 or as a name in a string (see signal for a list).

See also

signal, getpid


Install a signal action.


signal(sig, fun)


signal(sig,fun) installs function fun as the action for signal sig. fun can be a function name in a string, a function reference, or an inline function with neither input nor output argument; sig is the number of the signal between 1 and 31, or its name as a string. The following names are recognized (standard POSIX names compatible with the program or shell command kill and C header file signal.h); case is not significant, and names can be prefixed with 'sig'.


Note that signals 9 and 17 cannot be caught. Once a signal action has been installed, if the specified signal is sent to the LME application (typically with the LME or POSIX function kill), the function fun is executed as soon as possible, at a time when it does not corrupt the LME execution data. It can exchange information with the normal execution of LME via global variables; but semaphores cannot be used to guarantee exclusive access, because the signal action is not executed in a separate thread and locked semaphores could not be unlocked by the main thread.


Install a signal action which is triggered by signal usr1:

fun = inline('function f;fprintf(''Got signal usr1\n'');');
signal('usr1', fun);

Get process ID (the number is likely to be different):


From another shell, use the program or shell command kill to send a signal to LME:

kill -SIGUSR1 22716

See also

kill, threadnew