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.

Reply via email to