SIGUSR2 from GC interrupts application system calls on Linux
safety0ff via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 26 12:15:32 PDT 2016
On Thursday, 26 May 2016 at 18:44:22 UTC, ikod wrote:
> Hello,
>
> On linux, in the code below, receive() returns -1 with
> errno=EINTR if syscall is interrupted by GC (so you can see
> several "insterrupted") when GC enabled, and prints nothing
> (this is desired and expected behavior) when GC disabled.
>
> Is there any recommended workaround for this problem? Is this a
> bug?
Looks like recv is non-restartable and it should be called in a
loop.
>
> Looks like the reason of the problem is call sigaction(2)
> without SA_RESTART for SIGUSR2 (used by GC to restart suspended
> thread) in core.thread.
This isn't the cause, manually adding SA_RESTART using sigaction
made no difference:
import core.sys.posix.signal;
sigaction_t tmp;
sigaction(SIGUSR2, null, &tmp);
tmp.sa_flags |= SA_RESTART;
sigaction(SIGUSR2, &tmp, null);
This is because SIGUSR1 is the signal that actually interrupts
the system call, when SIGUSR2 is received the syscall is already
interrupted so the flag does not make a difference.
More information about the Digitalmars-d
mailing list