Platforms to show: All Mac Windows Linux Cross-Platform

Back to SignalHandlerMBS class.

SignalHandlerMBS.alarm(seconds as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 8.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Set signal timer alarm.
Example
SignalHandlerMBS.alarm 1

The alarm() function sets a timer to deliver the signal SIGALRM to the calling process after the specified number of seconds. If an alarm has already been set with alarm() but has not been delivered, another call to alarm() will supersede the prior call. The request alarm(0) voids the current alarm and the signal SIGALRM will not be delivered.

Due to setitimer restriction the maximum number of seconds allowed is 100000000.

alarm sends signal 14 after the time out.

SignalHandlerMBS.ClearFlag(signalIndex as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Clears the flag with given index.

Please call this after you got IsFlagSet.

Some examples using this method:

SignalHandlerMBS.ClearFlags

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Clears all flags.

SignalHandlerMBS.ClearStacktrace(signalIndex as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.2 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Clears stored stack trace for the signal with given index.

Some examples using this method:

SignalHandlerMBS.IsFlagSet(signalIndex as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Checks if a given flag was set.

Some examples using this method:

SignalHandlerMBS.QueryStacktrace(signalIndex as Integer, skip as Integer = 2) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.2 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Queries stack at the time the signal handler was triggered.

Useful to know later which code got the signal.
Works for flag handlers and for the event handlers if enabled.

Some examples using this method:

SignalHandlerMBS.SendSignal(PID as Integer, Signal as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 11.0 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Sends a signal.
Example
// send signal to a process
// PID is 17779 here
// 9 means kill on Mac OS X
call SignalHandlerMBS.SendSignal(17779, 9)

Returns true on success and false on failure.
Without a signal handler the target app could quit.

Lookup signal.h for the list of signals. They can be different on Mac and Linux.

SignalHandlerMBS.SendSignalToSelf(Signal as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 11.0 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Send a signal to the current process

Returns true on success and false on failure.
Without a signal handler the target app could quit.

SignalHandlerMBS.SetDefaultHandler(signalIndex as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 8.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Defines to use the default handler for the given signal number.
Example
Const SIGALRM = 14
if SignalHandlerMBS.SetDefaultHandler(SIGALRM) then
MsgBox "Done"
else
MsgBox "Failed"
end if

Returns true on success and false on failure.

Some examples using this method:

SignalHandlerMBS.SetFlagHandler(signalIndex as Integer, CollectStackTrace as boolean = false) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 14.0 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Defines to set the flag whenever a signal with the given number is received.

Returns true on success and false on failure.
Please use IsFlagSet in your app regularly to check if the flag was set.

If CollectStackTrace is true, you can later use QueryStacktrace to get the stack trace from the time the signal was captured.

Some examples using this method:

SignalHandlerMBS.SetIgnore(signalIndex as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 8.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Defines to ignore the event with the given number.
Example
Const SIGALRM = 14
if SignalHandlerMBS.SetIgnore(SIGALRM) then
MsgBox "Done"
else
MsgBox "Failed"
end if

Returns true on success and false on failure.

Some examples using this method:

SignalHandlerMBS.SetPrintBacktraceAndAbortHandler(signalIndex as integer) as boolean   New in 24.1

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 24.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Defines to use the plugin handler for the given signal number.
Example
Call SignalHandlerMBS.SetPrintBacktraceAndAbortHandler(4) // illegal instruction
Call SignalHandlerMBS.SetPrintBacktraceAndAbortHandler(10) // bus error
Call SignalHandlerMBS.SetPrintBacktraceAndAbortHandler(11) // segmentation fault

// now cause a crash
Dim p As ptr = Nil
p.Int32(0) = 0

The signal is handled by the plugin. We print the backtrace and abort.
We write details to a crash.txt file in the current folder.

SignalHandlerMBS.SignalStatus(signalIndex as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method System MBS Util Plugin 8.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Queries the signal state.

Returns 0 (unknown), kSignalDefault, kSignalEvent, kSignalFlag or kSignalIgnored.

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...