~ chicken-core (master) /manual/Module (chicken process signal)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken process signal)56This module offers procedures for dealing with POSIX process signals.78Please note that signals are very POSIX-specific. Windows only9supports rudimentary in-process signals for dealing with user10interrupts, segmentation violations, floating-point exceptions and the11like. Inter-process signals are not supported. Therefore, most of12the procedures here are not available on native Windows builds. If13that's the case, the description contains a note.141516=== set-alarm!1718<procedure>(set-alarm! SECONDS)</procedure>1920Sets an internal timer to raise the {{signal/alrm}}21after {{SECONDS}} are elapsed. You can use the22{{make-signal-handler}} procedure to write a handler for this signal.2324'''NOTE''': On native Windows builds (all except cygwin), this25procedure is unimplemented and will raise an error.2627=== make-signal-handler2829<procedure>(make-signal-handler SIGNUM ...)</procedure>3031Establishes a handler for the POSIX signals with the numbers {{SIGNUM ...}} and returns32a procedure of zero or one argument. Should one of the given signals be raised, then it will be stored in a33queue. Invoking the procedure returned by {{make-signal-handler}} with zero arguments or34with the argument {{#f}} will remove the oldest35entry in the queue and return it to the caller. Invoking the procedure with argument {{#t}} when no signal was36raised since the creation of the signal handler or the most recent call to the handler37will result in suspending the execution until one of the signals given in {{SIGNUM ...}}38occurs.3940Notes:4142* when signals arrive in quick succession (specifically, before the handler for a signal has been started), then signals will be queued (up to a certain limit); the order in which the queued signals will be handled is not specified4344* Any signal handlers for the signals {{signal/segv}}, {{signal/bus}}, {{signal/fpe}} and {{signal/ill}} will be ignored and these signals will always trigger an exception, unless the executable was started with the {{-:S}} runtime option. This feature is only available on platforms that support the {{sigprocmask(3)}} POSIX API function.4546=== signal-ignore4748<procedure>(signal-ignore SIGNUM)</procedure>4950Ignores any future occurrences if the signal {{SIGNUM}} by setting its disposition to {{SIG_IGN}}.5152=== signal-default5354<procedure>(signal-default SIGNUM)</procedure>5556Sets the default disposition for the signal {{SIGNUM}} by setting its disposition to {{SIG_DFL}}.5758=== set-signal-mask!5960<procedure>(set-signal-mask! SIGLIST)</procedure>6162Sets the signal mask of the current process to block all signals given63in the list {{SIGLIST}}. Signals masked in that way will not be64delivered to the current process.6566'''NOTE''': On native Windows builds (all except cygwin), this67procedure is unimplemented and will raise an error.6869=== signal-mask7071<procedure>(signal-mask)</procedure>7273Returns the signal mask of the current process.7475'''NOTE''': On native Windows builds (all except cygwin), this76procedure is unimplemented and will raise an error.7778=== signal-masked?7980<procedure>(signal-masked? SIGNUM)</procedure>8182Returns whether the signal for the code {{SIGNUM}} is currently masked.8384'''NOTE''': On native Windows builds (all except cygwin), this85procedure is unimplemented and will raise an error.8687=== signal-mask!8889<procedure>(signal-mask! SIGNUM)</procedure>9091Masks (blocks) the signal for the code {{SIGNUM}}.9293'''NOTE''': On native Windows builds (all except cygwin), this94procedure is unimplemented and will raise an error.9596=== signal-unmask!9798<procedure>(signal-unmask! SIGNUM)</procedure>99100Unmasks (unblocks) the signal for the code {{SIGNUM}}.101102'''NOTE''': On native Windows builds (all except cygwin), this103procedure is unimplemented and will raise an error.104105=== Signal codes106107<constant>signal/term</constant><br>108<constant>signal/kill</constant><br>109<constant>signal/int</constant><br>110<constant>signal/hup</constant><br>111<constant>signal/fpe</constant><br>112<constant>signal/ill</constant><br>113<constant>signal/segv</constant><br>114<constant>signal/abrt</constant><br>115<constant>signal/trap</constant><br>116<constant>signal/quit</constant><br>117<constant>signal/alrm</constant><br>118<constant>signal/vtalrm</constant><br>119<constant>signal/prof</constant><br>120<constant>signal/io</constant><br>121<constant>signal/urg</constant><br>122<constant>signal/chld</constant><br>123<constant>signal/cont</constant><br>124<constant>signal/stop</constant><br>125<constant>signal/tstp</constant><br>126<constant>signal/pipe</constant><br>127<constant>signal/xcpu</constant><br>128<constant>signal/xfsz</constant><br>129<constant>signal/usr1</constant><br>130<constant>signal/usr2</constant><br>131<constant>signal/bus</constant><br>132<constant>signal/winch</constant><br>133<constant>signal/break</constant><br>134<constant>signals-list</constant><br>135136These variables contain signal codes for use with {{process-signal}},137{{set-signal-handler!}}, {{signal-handler}}, {{signal-masked?}},138{{signal-mask!}}, or {{signal-unmask!}}.139140'''NOTE''': On native Windows builds (all except cygwin), only141{{signal/term}}, {{signal/int}}, {{signal/fpe}}, {{signal/ill}},142{{signal/segv}}, {{signal/abrt}}, {{signal/break}} have an actual143value. The others are all defined as zero, because those signals144don't exist on Windows.145146'''NOTE''': On UNIX builds and cygwin, {{signal/break}} is defined as147zero because it only exists on Windows.148149To get a list of signals that are known to exist on the current150platform, you can check {{signals-list}} which is a list of integers151(signal numbers).152153---154Previous: [[Module (chicken process)]]155156Next: [[Module (chicken process-context)]]