clisp - how to retrieve errno from an os error? -
this question divided 2 parts.
part one:
i run ...
1 (handler-case (posix:kill 1 0) 2 (error (the-condition) (prin1 (type-of the-condition)) (terpri) 3 (princ the-condition) (terpri)))
... , output:
system::simple-os-error unix error 1 (eperm): operation not permitted
i can use #'princ-to-string
, parse string error number. there more direct way retrieve errno
? #'file-error-pathname
, errno
instead?
part two:
where in documentation have found answer part one?
released version
the released version 2.49 not have accessor errno. can it, however, thusly:
[4]> (setq c (nth-value 1 (ignore-errors (posix:kill 1 0)))) #<system::simple-os-error #x00000002002634a1> [5]> (describe c) #<system::simple-os-error #x000000020021af69> instance of clos class #1=#<standard-class system::simple-os-error>. slots: system::$format-control = "unix error ~s (eperm): operation not permitted " system::$format-arguments = (1) "unix error ~s (eperm): operation not permitted " simple 1 dimensional array (vector) of characters, of size 47 (a iso-8859-1 string). (1) list of length 1. [6]> (car (slot-value c 'system::$format-arguments)) 1
development version
the dev version in tip of mercurial repo has os-error
instead:
[1]> (setq c (nth-value 1 (ignore-errors (posix:kill 1 0)))) #<os-error #x0000000200253301> [2]> (describe c) #<os-error #x0000000200253301> instance of clos class #1=#<standard-class os-error>. slots: system::$code = 1 1 integer, uses 1 bit, represented fixnum. [6]> (apropos "os-error") os-error class os-error-code function ext::os-error-code-1 [10]> (os-error-code c) 1
Comments
Post a Comment