[GAP] Asynchroneus IO on Mac OS X
Christfried Webers
christfried.webers at ieee.org
Sat Sep 9 08:01:41 CEST 2006
Ted,
many thanks for your response. Please see my comments below.
Best
Chris
--On 8 September 2006 12:34:27 -0400 Ted Baker <baker at cs.fsu.edu> wrote:
> I would be interested in hearing about the resolution of this
> problem. When I wrote the code for signal handling I do not think
> I made any distinction for SIGIO.
>
> One possibility is that the signal has been reserved. There are
> some signals that are excluded from handling by an application,
> including those used by internally by the Ada runtime system and
> those used by certain thread libraries. For example, I think the
> FSU thread library installs its own handler for SIGIO in order to
> implement non-blocking reads and writes. (Florist tries to
> auto-configure the set of signals that can be handled by various
> means, but the autoc-onfiguration cannot be 100% correct.) If the
> signal is reserved, you really should get an exception when you
> try to bind a handler to it.
On the "man signal" pages, I found that the default action
for Mac OS X is to disregard SIGIO.
No Name Default Action Description
-------------------------------------------------------------------
1 SIGHUP terminate process terminal line hangup
...
23 SIGIO discard signal I/O is possible on a descriptor
(see fcntl(2))
I don't know, what the Ada runtime does when it starts up. But I assume
it has to deal with the inherited signal mask and the jump table for
the signal handlers.
I tried to change the signal mask from the Ada side of the process by
enabling all signals, but this did not help.
On the other hand, installing an Ada procedure as a handler
via the C library call sigaction() catches the SIGIO signals.
That means at least, the operating system delivers SIGIO as soon as
sigaction() installs a handler.
Fazit: The Ada program accepts to attach a handler to an interrupt
via pragma Attach_Handler. But it does not enable/activate signal
delivery from the OS.
Whether there is any reliable way to detect this situation at
the initialisation of the Ada runtime is beyond my knowledge.
Maybe you can comment on this.
> Another possibility is that the signal is not being generated,
> because it was not enabled for that file. I suppose that you did
> remember to enable SIGIO, using fcntl?
I have set the file descriptor to be owned by the process
Res := Syscall_Fcntl (C.int (File), F_SETOWN, Process_Id);
(also tried the process group
Res := Syscall_Fcntl (C.int (File), F_SETOWN, -Process_Id);)
and to asynchronous and nonblocking
Res := Syscall_Fcntl (C.int (File), F_SETFL, FASYNC + O_NONBLOCK);
> Either way, it seems you should be able to work around this by
> using fcntl with F_SETSIG to change over to a different signal.
> Did you try that?
F_SETSIG is Linux specific and therefore not available on MAC OS X.
More information about the GAP
mailing list