[net.bugs.4bsd] Socket

dal@philabs.UUCP (Dan Lorenzini) (08/28/84)

We are Philips Research Laboratory of Brussels, we are not (yet) on Usenet
but we can thanks to the amiability of Dan Lorenzini of philabs post it to
the net.

Apparently, 4.2 hangs when:
	- a socket(2) is select(2)ed for accept(2)
	- another process does a connect(2)
	- the server exits before accepting the connect request
Just run the following program:

#include <sys/types.h>
#include <sys/socket.h>
#define SOCKET "/tmp/sck"
struct sockaddr sa={AF_UNIX,SOCKET};
int s,m,d;
main() {
	unlink(SOCKET);
	if ((s = socket(AF_UNIX , SOCK_STREAM , 0)) < 0) perror("socket");
	if (bind(s, &sa, 10) < 0) perror("bind");
	if (listen(s, 1) < 0) perror("listen");
	if (fork() == 0) {
		d = socket(AF_UNIX , SOCK_STREAM , 0);
		if (d < 0) perror("child socket");
		if (connect(d, &sa, 10) < 0) perror("connect");
		sleep(10);
		}
	m = 1 << s;
	if (select(20, &m, 0, 0, 0) < 0) perror("select");
	exit(0);
}
----------------------------------------------------------------------------
Please answer by mail. We can be reached by mail at the following addresses :

	...!philabs!prlb2!heymans
	...!decvax!cca!prlb2!heymans

					Franz Heymans