From owner-freebsd-questions Thu Aug 29 1:15:13 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E539137B400 for ; Thu, 29 Aug 2002 01:15:06 -0700 (PDT) Received: from cs78135006.pp.htv.fi (cs78135006.pp.htv.fi [62.78.135.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id C073D43E3B for ; Thu, 29 Aug 2002 01:15:05 -0700 (PDT) (envelope-from jau@cs78135006.pp.htv.fi) Received: (from jau@localhost) by cs78135006.pp.htv.fi (8.9.3/8.9.3/JAU-2.2) id LAA67038 for freebsd-questions@freebsd.org; Thu, 29 Aug 2002 11:15:03 +0300 (EEST) Message-Id: <200208290815.LAA67038@cs78135006.pp.htv.fi> Subject: UNIX/LOCAL domain sockets and SIGIO To: freebsd-questions@freebsd.org Date: Thu, 29 Aug 2002 11:15:03 +0300 (EET DST) Reply-To: jau@iki.fi From: jau@iki.fi (Jukka A. Ukkonen) Latin-Date: Joi XXIX August a.d. MMII Organization: Private person OS-Platform: FreeBSD 3.5.1-RELEASE i386 Phone: +358-9-6215280 (home) Content-Conversion: prohibited X-Mailer: ELM [version 2.4 PL25+pgp] MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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