[Issue 17296] EINTR awareness - posix system calls can be interrupted by posix signal

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 5 12:20:46 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17296

--- Comment #1 from Roman <freeslave93 at gmail.com> ---
It turned out that the problem can appear even if user does not do signal
handling himself. It's enough to just do multithreading, so signals used by GC
can interrupt syscall in other thread.

Whether the hack is applied or not, the behavior of functions will need to be
documented. If hack is applied, it should say about possible looping, if it's
not applied it should say that interruption is considered error for these
functions.

There's also updated version of the hack:

template deintr(alias func) 
if (isFunction!func && isIntegral!(ReturnType!func) && 
    isSigned!(ReturnType!func) && functionLinkage!func == "C")
{
    ReturnType!func deintr(Args...)(Parameters!func args, Args varArgs)
    {
        ReturnType!func result;
        do 
        {
            result = func(args, varArgs);
        }
        while(result == -1 && .errno == EINTR);
        return result;
    }
}

--


More information about the Digitalmars-d-bugs mailing list