Date: Fri, 21 Dec 2018 22:04:52 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 234258] SIGIO not delivered on socket when incoming connection arrives Message-ID: <bug-234258-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D234258 Bug ID: 234258 Summary: SIGIO not delivered on socket when incoming connection arrives Product: Base System Version: 12.0-RELEASE Hardware: i386 OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: adelman@adelman.com If a socket is set: fcntl(sock, F_SETOWN, getpid()) and=20 fcntl(sock, F_SETFL,O_ASYNC) when a connection arrives a SIGIO signal should be delivered to the appropr= iate process. Under FreeBSD 11.2 and prior releases, this works. Under FreeBSD 12.0-RELEASE, no signal is delivered. This is the case with at least TCP a= nd UNIX domain sockets. Duplicate by compiling and running the attached source code. "telnet 127.0.= 0.1 2666" to tickle the code with an incoming connection. Expected behavior is = for the signal handler to fire and print "signalfired(): SIGIO fired" to stderr. Under FreeBSD 11.2 and prior (back to at least FreeBSD 2 the code that reli= ed on this worked), this works. Under FreeBSD 12.0-RELEASE the signal is not delivered. #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> #include <signal.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> static void signalfired() { fprintf(stderr,"signalfired(): SIGIO fired\n"); } int main(void) { int sock; struct sockaddr_in sin =3D { AF_INET }; /* socket address */ sin.sin_addr.s_addr =3D INADDR_ANY; sin.sin_port =3D htons(2666); sock =3D socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket"); exit(1); } if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0){ perror("bind"); exit(1); } if (signal(SIGIO,(void *) signalfired)) { perror("trapping signal"); exit(1); } if (fcntl(sock, F_SETOWN, getpid()) =3D=3D -1) { perror("fcntl(F_SETOWN)"); exit(1); } if (fcntl(sock, F_SETFL, O_ASYNC) =3D=3D -1) { perror("fcntl(F_SETFL)"); exit(1); } if (listen(sock, 10) < 0) { perror("listen"); exit(1); } fprintf(stderr,"sleeping, test by \"telnet localhost %d\"\n",2666); sleep(10000); } --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-234258-227>