Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[cl21.process] Use trivial-signal? #96

@epipping

Description

@epipping

process.lisp currently hardcodes

(defconstant +sigkill+ 9)
(defconstant +sigterm+ 15)
(defconstant +sigstop+ 17)
(defconstant +sigcont+ 19)

Naturally, this list is incomplete, but it's also clearly not portable (e.g. SIGSTOP is 17 on my macOS box and 19 on my linux box). If one can rely on CFFI, this issue can be trivially solved (and trivial-signal has done that, I believe).

If one does not want to depend on CFFI directly for whatever reason: Quite a few CL implementations give access to a name-to-number signal translation facility one way or another. Here's a bit of sample code:

(defmacro %resolve-symbol (symbol package)
  `(symbol-value (find-symbol (symbol-name ,symbol) ,package)))

(defmacro define-signal (name
                         regular-symbol variable-symbol constant-symbol)
  (declare (ignore
            #-(or clozure cmucl mkcl sbcl) regular-symbol
            #-(or allegro) variable-symbol
            #-(or ecl) constant-symbol))
  `(defconstant ,name
     #+allegro (%resolve-symbol ,variable-symbol :excl)
     #+clozure (symbol-value (read-from-string
                              ,(concatenate 'string "#$"
                                            (string-upcase
                                             (symbol-name regular-symbol)))))
     #+cmucl (%resolve-symbol ,regular-symbol :unix)
     #+ecl (%resolve-symbol ,constant-symbol :ext)
     #+mkcl (progn (require :mk-unix)
                   (%resolve-symbol ,regular-symbol :mk-unix))
     #+sbcl (progn (require :sb-posix)
                   (%resolve-symbol ,regular-symbol :sb-posix))))

(define-signal +sigstop+ :sigstop :*sigstop* :+sigstop+)

(Warning: There's a bug in Allegro CL 10.0: SIGCONT is not defined. I've already reported this.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions