Date: Thu, 29 Aug 2002 11:15:03 +0300 (EET DST) From: jau@iki.fi (Jukka A. Ukkonen) To: freebsd-questions@freebsd.org Subject: UNIX/LOCAL domain sockets and SIGIO Message-ID: <200208290815.LAA67038@cs78135006.pp.htv.fi>
next in thread | raw e-mail | index | archive | help
Hi all!
Isn't FreeBSD (well any UNIX/POSIX in general) supposed to
deliver a SIGIO (or SIGURG) when passive UNIX domain sockets
(for which listen(2) has been called) receive connections
and they have been put to async mode?
For some odd reason I see neither of those signals though
the embryonic connection definitely is there...
Active UNIX domain sockets
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
ced912c0 stream 0 0 0 ced917c0 0 0 /tmp/watchdog/testproc/66902
ced917c0 stream 0 0 0 ced912c0 0 0
ced91380 stream 0 0 cf132580 0 0 0 /tmp/watchdog/testproc/66902
Because my code is waiting in sigsuspend() it never gets to
doing select() and accept() unless some other socket becomes
readable which generates the SIGIO as expected. I definitely
need the new incoming connections to generate signals to break
out from waiting inside sigsuspend().
To avoid any speculation about what important things to do
might be forgotten in my code I attach the related lines at
the end of this message.
This UNIX/LOCAL domain socket is supposed to be a sort of
light weight monitoring interface for a program the primary
purpose of which is entirely unrelated to this problem.
The PR database did not contain anything related to SIGIO.
Is this a real bug in FreeBSD or am I just totally lost in
my own tangled code?
Cheers,
// jau
.--- ..- -.- -.- .- .- .-.-.- ..- -.- -.- --- -. . -.
/ Jukka A. Ukkonen, Mawit Ltd, Finland
/__ M.Sc. (sw-eng & cs) (Phone) +358-500-606-671
/ Internet: Jukka.Ukkonen(a)Mawit.Com (Home) +358-9-6215-280
/ Internet: ukkonen(a)nic.funet.fi
v Internet: jau(a)iki.fi
+ + + + My opinions are mine and mine alone, not my employers. + + + +
o
\ /
- X ------------------------- clip clip ------------------------------
/ \
O
listen_sock = socket (PF_LOCAL, SOCK_STREAM, 0);
if (listen_sock < 0) {
report_error (LOG_ALERT,
"socket (PF_LOCAL): %s, exiting\n", strerror (errno));
exit (-1);
}
memset (&sa, '\0', sizeof (sa));
sa_size = 0;
/*
* Initialize the socket "address"
* i.e. a path name in the file system.
*/
mkdir (WATCHDOG_BASEDIR, 0777); /* Failure will be noticed later */
chmod (WATCHDOG_BASEDIR, 01777);
sprintf (sockpath, "%s/%s",
WATCHDOG_BASEDIR, basename (av[optind]));
mkdir (sockpath, 0777);
chmod (sockpath, 01777);
sprintf (sockpath, "%s/%s/%u",
WATCHDOG_BASEDIR, basename (av[optind]), mypid);
sa.sun_family = AF_LOCAL;
strncpy (sa.sun_path, sockpath, sizeof (sa.sun_path));
sa.sun_path[sizeof (sa.sun_path) - 1] = '\0';
sa_size = offsetof (struct sockaddr_un, sun_path) + strlen (sa.sun_path);
#if defined(BSD) && (BSD >= 199303)
sa.sun_len = sa_size;
#endif
/* See the limited copying above. */
if (strlen (sa.sun_path) < strlen (sockpath)) {
report_error (LOG_ALERT,
"%s: path name too long for a LOCAL domain socket "
"- exiting\n",
sockpath);
exit (-1);
}
if (bind (listen_sock, (struct sockaddr *) &sa, sa_size) < 0) {
report_error (LOG_ALERT,
"bind (listen_sock, ...): %s: %s, exiting\n",
sa.sun_path, strerror (errno));
exit (-1);
}
if (listen (listen_sock, 32) < 0) {
report_error (LOG_ALERT,
"listen (listen_sock, 32); %s, exiting\n",
strerror (errno));
unlink (sa.sun_path);
exit (-1);
}
n = fcntl (listen_sock, F_SETOWN, mypid);
#ifdef FIOASYNC
n = ioctl (listen_sock, FIOASYNC, &true);
#endif
n = fcntl (listen_sock, F_GETFL, &sockflags);
#ifdef O_ASYNC
sockflags |= O_ASYNC;
#endif
sockflags |= O_NONBLOCK;
n = fcntl (listen_sock, F_SETFL, &sockflags);
n = fcntl (listen_sock, F_GETFD, &sockflags);
sockflags |= FD_CLOEXEC;
n = fcntl (listen_sock, F_SETFD, &sockflags);
/*
.
. ... much later...
.
*/
while (1) {
sigsuspend (&susp_sigs); /* ~= pause() */
/*
.
. ... do select() to find out which sockets
. have some activity and do accept if/when
. the listen_sock becomes ready.
.
*/
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208290815.LAA67038>
