Subject: Re: [PATCH] net: unix: non blocking recvmsg() should not return -EINTR

From: Rainer Weikusat <[email-masked]>
Date: Wed, 26 Mar 2014 21:21:23 +0000

David Miller <[email-masked]> writes:
> From: Rainer Weikusat <[email-masked]>:
>> As I already wrote, this is a theoretical problem with no really
>> satisfactory solution minus noting that both 'nonblocking sockets' and
>> 'multithreaded kernels' are somewhat alien concepts when considering the
>> system where EINTR originated (AFAIK).
>
> I completely disagree.

And I "completely disagree" with having written the text above, that is
minus the "reporting EAGAIN when the call was really interrupted by a
signal is inaccurate" and "for pragmatic reasons, the kernel should
behave in line with common expectations about its behaviour" parts which
means

a) This is an 'interesting theoretical problem to me' (but maybe not to
   you)

b) my suggestion would be to apply the patch regardless of it.

BTW, here's the program with the O_NONBLOCK read call which blocks until
the end of electricity, at least on 3.2.9:

---------
#include <fcntl.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>

int main(void)
{
    struct sockaddr_un sun;
    int fd;

    fd = socket(AF_UNIX, SOCK_DGRAM, 0);
    sun.sun_family = AF_UNIX;
    strncpy(sun.sun_path, "/tmp/bla", sizeof(sun.sun_path));
    bind(fd, (struct sockaddr *)&sun, sizeof(sun));

    if (fork() == 0) read(fd, &fd, sizeof(fd));

    sleep(1);

    fcntl(fd, F_SETFL, O_NONBLOCK);
    read(fd, &fd, sizeof(fd));

    return 0;
}
--------