lkml.org 
[lkml]   [2001]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectKernel bug with UNIX sockets not detecting other end gone?

Hi,

I wonder if the following is a bug? It certainly differs from FreeBSD 4.2
behaviour, which gives the behaviour I would expect.

The following program blocks indefinitely on Linux (2.2, 2.4 not tested).
Since the other end is clearly gone, I would expect some sort of error
condition. Indeed, FreeBSD gives ECONNRESET.

#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>

int
main(int argc, const char* argv[])
{
int the_sockets[2];
int retval;
char the_char;
int opt = 1;

retval = socketpair(PF_UNIX, SOCK_DGRAM, 0, the_sockets);
if (retval != 0)
{
perror("socketpair");
exit(1);
}
close(the_sockets[0]);
/* Linux (2.2) blocks here; FreeBSD does not */
retval = read(the_sockets[1], &the_char, sizeof(the_char));
}

Cheers
Chris

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:53    [W:0.079 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site