The errno and signal codesets Lassi Kortela (13 Dec 2022 11:38 UTC)
Re: The errno and signal codesets Lassi Kortela (13 Dec 2022 11:48 UTC)
Re: The errno and signal codesets John Cowan (14 Dec 2022 05:58 UTC)
Re: The errno and signal codesets Lassi Kortela (14 Dec 2022 09:08 UTC)
Re: The errno and signal codesets John Cowan (14 Dec 2022 22:48 UTC)
Re: The errno and signal codesets Lassi Kortela (15 Dec 2022 09:10 UTC)
Re: The errno and signal codesets John Cowan (18 Dec 2022 07:56 UTC)
Re: The errno and signal codesets Lassi Kortela (20 Dec 2022 10:51 UTC)
Re: The errno and signal codesets Lassi Kortela (20 Dec 2022 11:53 UTC)

Re: The errno and signal codesets Lassi Kortela 20 Dec 2022 10:51 UTC

>     - "Process exited with signal 6" -> look up which signal.
>
> I think we are talking past one another.  That is the function of
> `codeset-symbol`, translating a 6 into the symbol SIGABRT.

True.

> But why
> you'd want to translate SIGABRT into 6 (which is what `codeset-number`
> does) is a mystery to me.  Presumably Scheme procedures would accept
> SIGABRT rather than 6.

They don't. It's early days of HLL-LLL wrappers. Abstractions are leaky.

E.g. Gauche:

 > (sys-kill (sys-getpid) 'SIGINT)
*** ERROR: ScmSmallInt required, but got SIGINT

but this works:

 > (sys-kill (sys-getpid) (codeset-number 'signal 'SIGINT))

Took two minutes to find this example. There are sure to be many more.

As a mixed-level programmer, I also want to get a feel for the
territory. With codeset-number, you can do things like this:

(list-sort (lambda (a b) (< (codeset-number 'errno a) (codeset-number
'errno b))) (codeset-symbols 'errno))
=> (EPERM ENOENT ESRCH EINTR EIO ENXIO E2BIG ENOEXEC EBADF ECHILD
EDEADLK ENOMEM
  EACCES EFAULT ENOTBLK EBUSY EEXIST EXDEV ENODEV ENOTDIR EISDIR EINVAL
ENFILE
  EMFILE ENOTTY ETXTBSY EFBIG ENOSPC ESPIPE EROFS ...)

Here we can see the evolution of the codeset over time, the low errno's
are older and more stable. Introspection is an important goal of the
SRFI, and I don't think the introspection facilities are as useful if
the mapping is not bidirectional.