... | ... | @@ -83,13 +83,17 @@ The solution we use, on both Windows and POSIX systems, is to pass all signals t |
|
|
|
|
|
When using foreign libraries through the Haskell FFI, it is important
|
|
|
to ensure that the foreign code is capable of dealing with system call
|
|
|
interrupts due to alarm signals. For example, in this `strace` output
|
|
|
interrupts due to alarm signals GHC is generating.
|
|
|
|
|
|
|
|
|
For example, in this `strace` output
|
|
|
a `select` call is interrupted, but the foreign C code interprets the
|
|
|
interrupt as an application error and closes a critical file
|
|
|
descriptor:
|
|
|
|
|
|
```wiki
|
|
|
[pid 22338] send(7, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 116, MSG_NOSIGNAL) = 116
|
|
|
[pid 22338] send(7, "\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
|
|
|
\0\0\0\0\0\0\0\0\0\0\0"..., 116, MSG_NOSIGNAL) = 116
|
|
|
[pid 22338] select(8, [7], NULL, NULL, NULL) = ? ERESTARTNOHAND (To be restarted)
|
|
|
[pid 22338] --- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
|
|
|
[pid 22338] sigreturn() = ? (mask now [])
|
... | ... | @@ -101,7 +105,7 @@ descriptor: |
|
|
|
|
|
|
|
|
Once the C code was modified to deal with the interrupt properly, it
|
|
|
proceeded correctly:
|
|
|
proceeded correctly (note that foreign call is restarted 3 times before it succeeds).
|
|
|
|
|
|
```wiki
|
|
|
[pid 23967] send(7, "\f\0\0\0\244\1\0\0\0\0\0\0B\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 536, MSG_NOSIGNAL <unfinished ...>
|
... | ... | |