[Bug 234258] SIGIO not delivered on socket when incoming connection arrives
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Fri Dec 21 22:04:55 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234258
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 at FreeBSD.org
Reporter: adelman at adelman.com
If a socket is set:
fcntl(sock, F_SETOWN, getpid()) and
fcntl(sock, F_SETFL,O_ASYNC)
when a connection arrives a SIGIO signal should be delivered to the appropriate
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 and
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 relied
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 = { AF_INET }; /* socket address */
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(2666);
sock = 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()) == -1) {
perror("fcntl(F_SETOWN)");
exit(1);
}
if (fcntl(sock, F_SETFL, O_ASYNC) == -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);
}
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list