set-sigio-handler

Function

Package: system

Arguments: fd function

Sigio handling is not supported on Windows.

This function is used for its side effects. Its return value is not specified. Calling this function establishes function as the sigio handler for the Unix file descriptor fd. Sigio handling should be initialized before using the function with initialize-sigio-handling.

fd should be an integer identifying a Unix file descriptor. (We assume that the file descriptor has been established by a call to a Unix I/O operation such as open() and returned to Lisp via a call to a foreign function.)

function should be a symbol naming a function. The function must accept one argument. The system will pass it the file descriptor number fd when it is called.

Note that only input signals are available to Allegro CL. (Output signals are filtered out.) Note too that SIGIO handlers will only work if the SIGIO interface is available, as indicated by the return value of the function sigio-supported-p.

Signal handlers are removed with remove-sigio-handler.

Here is an example of a SIGIO function.

;; Assume that MY-FD is a UNIX file descriptor
;; returned by a foreign
;; function and that the function MY-GET-EVENT-HANDLER returns a
;; process
;;
;; This function shows how to schedule an event-handler associated
;; with the file descriptor to execute as soon as safely possible.
;; This way, data (from say a window or other input device) can be
;; processed sooner than it normally would be were lisp to wait for
;; the event-handler to be run by normal scheduling sequence.

(defun my-sigio-handler (fd)
  (mp:without-interrupts
     (let ((event-handler (my-get-event-handler fd)))
       (when (and mp:*current-process* ; Not in scheduler stack group
                  (not sys:*disallow-scheduling*) ; Avoid MP hazards
         (process-active-p event-handler)
         (not (eq mp:*current-process* event-handler)))
         (mp:process-allow-schedule event-handler)))))

(sys:set-sigio-handler my-fd 'my-sigio-handler)

Note the polling of *disallow-scheduling* to avoid multiprocessing hazards.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.