Next: , Previous: , Up: posix   [Index]


4.8 Delivering signals to processes

Function: raise signum

Interface to the C function raise(), (libc)raise. Send the selected signal to the calling process. If successful return zero, else raise an exception.

Function: kill pid signum

Interface to the C function kill(), (libc)kill. Send the selected signal to selected process. If successful return zero, else raise an exception.

Function: pause

Interface to the C function pause(), (libc)pause. Suspend the process until a signal is received; return the void object.

Block/unblock signals handling

The block/unblock (BUB) API is a simplified interface to detect the arrival of interprocess signals; if it does not suit the application’s model, we should just ignore it. It is impossible to use the BUB API along with other interprocess signal APIs. Here is a meaningless usage example:

(import (vicare)
  (prefix (vicare posix) px.)
  (vicare platform constants))

(px.signal-bub-init)

(px.raise SIGUSR1)
(px.signal-bub-acquire)

(px.signal-bub-delivered? SIGUSR1) ⇒ #t
(px.signal-bub-delivered? SIGUSR2) ⇒ #f

(signal-bub-final)
Function: signal-bub-init

Block all the signals and initialise the BUB interface.

Function: signal-bub-final

Set all the signal handlers to SIG_IGN, then unblock all the signals and finalise the BUB interface.

Function: signal-bub-acquire

Unblock all the signals, then block them again. This should allow all the pending signals to be delivered to the process.

Function: signal-bub-delivered? signum

Return #t if the signal signum has been delivered at least once before the last call to signal-bub-acquire. Calling this function with signum clears the internal flag for this signal, so calling it again without acquiring new signals always returns #f.

This function interferes with signal-bub-all-delivered.

Function: signal-bub-all-delivered

Return a list of fixnums representing the signals delivered before the last call to signal-bub-acquire. Calling this function clears the internal flags for all the signals, so calling it again without acquiring new signals always returns the empty list.

This function interferes with signal-bub-delivered?.

Synchronously waiting for signals

Struct Type: struct-siginfo_t

Scheme representation of the C language type siginfo_t which is a structure typedef. It has the following fields (some of them are not present on all the architectures):

si_signo

Signal number.

si_errno

An errno value.

si_code

Signal code.

si_trapno

Trap number that caused hardware–generated signal (unused on most architectures).

si_pid

Sending process ID.

si_uid

Real user ID of sending process.

si_status

Exit value or signal.

si_utime

User time consumed.

si_stime

System time consumed.

si_value.sival_int
si_value.sival_ptr

Signal value. The C language type sigval_t is a union with fields int sival_int and void *sival_ptr.

si_int

POSIX.1b signal.

si_ptr

POSIX.1b signal.

si_overrun

Timer overrun count; POSIX.1b timers.

si_timerid

Timer ID; POSIX.1b timers.

si_addr

Memory location which caused fault.

si_band

Band event.

si_fd

File descriptor.

si_addr_lsb

Least significant bit of address.

NOTE On GNU+Linux: for details on the struct siginfo_t type see the manual page sigaction(2).

Function: make-struct-siginfo_t
Function: make-struct-siginfo_t signo errno code trapno pid uid status utime stime value-int value-ptr int ptr overrun timerid addr band fd addr_lsb

Build and return a new instance of struct-siginfo_t. If no arguments are given: all the fields are initialised to #f.

Function: struct-siginfo_t? obj

Return #t if obj is an instance of struct-siginfo_t.

Function: struct-siginfo_t-si_signo info
Function: struct-siginfo_t-si_errno info
Function: struct-siginfo_t-si_code info
Function: struct-siginfo_t-si_trapno info
Function: struct-siginfo_t-si_pid info
Function: struct-siginfo_t-si_uid info
Function: struct-siginfo_t-si_status info
Function: struct-siginfo_t-si_utime info
Function: struct-siginfo_t-si_stime info
Function: struct-siginfo_t-si_value.sival_int info
Function: struct-siginfo_t-si_value.sival_ptr info
Function: struct-siginfo_t-si_int info
Function: struct-siginfo_t-si_ptr info
Function: struct-siginfo_t-si_overrun info
Function: struct-siginfo_t-si_timerid info
Function: struct-siginfo_t-si_addr info
Function: struct-siginfo_t-si_band info
Function: struct-siginfo_t-si_fd info
Function: struct-siginfo_t-si_addr_lsb info

Accessors for the fields of struct-siginfo_t.

Function: set-struct-siginfo_t-si_signo! info value
Function: set-struct-siginfo_t-si_errno! info value
Function: set-struct-siginfo_t-si_code! info value
Function: set-struct-siginfo_t-si_trapno! info value
Function: set-struct-siginfo_t-si_pid! info value
Function: set-struct-siginfo_t-si_uid! info value
Function: set-struct-siginfo_t-si_status! info value
Function: set-struct-siginfo_t-si_utime! info value
Function: set-struct-siginfo_t-si_stime! info value
Function: set-struct-siginfo_t-si_value.sival_int! info value
Function: set-struct-siginfo_t-si_value.sival_ptr! info value
Function: set-struct-siginfo_t-si_int! info value
Function: set-struct-siginfo_t-si_ptr! info value
Function: set-struct-siginfo_t-si_overrun! info value
Function: set-struct-siginfo_t-si_timerid! info value
Function: set-struct-siginfo_t-si_addr! info value
Function: set-struct-siginfo_t-si_band! info value
Function: set-struct-siginfo_t-si_fd! info value
Function: set-struct-siginfo_t-si_addr_lsb! info value

Mutators for the fields of struct-siginfo_t.

Function: sigwaitinfo signo
Function: sigwaitinfo signo siginfo

Interface to the C function sigwaitinfo(), see the manual page sigwaitinfo(2). Synchronously wait for a queued signal; if successful return two values: a fixnum representing a signal number and siginfo; else raise an exception.

signo must be a fixnum representing an interprocess signal code.

The optional siginfo must be an instance of struct-siginfo_t, which is filled with the informations attached to the signal; when not given a new instance is allocated internally.

#!r6rs
(import (vicare)
  (prefix (vicare posix) px.)
  (vicare platform constants)
  (vicare language-extensions syntaxes))

(px.signal-bub-init)
(px.raise SIGALRM)
(let-values
    (((signo info) (px.sigwaitinfo SIGALRM)))
  signo ⇒ SIGALRM
  (px.struct-siginfo_t-si_signo info)) ⇒ SIGALRM
Function: sigtimedwait signo timeout
Function: sigtimedwait signo siginfo timeout

Interface to the C function sigtimedwait(), see the manual page sigtimedwait(2). Synchronously wait for a queued signal, with a timeout; if successful return two values: a fixnum representing a signal number and siginfo; else raise an exception.

signo must be a fixnum representing an interprocess signal code.

siginfo must be an instance of struct-siginfo_t, which is filled with the informations attached to the signal; when not given a new instance is allocated internally.

timeout must be an instance of struct-timespec: it represents the maximum interval of time to wait for the signal; posix time timespec for details.

#!r6rs
(import (vicare)
  (prefix (vicare posix) px.)
  (vicare platform constants)
  (vicare language-extensions syntaxes))

(px.signal-bub-init)
(px.raise SIGUSR1)
(let-values
    (((signo info)
      (px.sigtimedwait SIGUSR1
                       (px.make-struct-timespec 1 0))))
  signo ⇒ SIGUSR1
  (px.struct-siginfo_t-si_signo info)) ⇒ SIGUSR1

Next: , Previous: , Up: posix   [Index]