From owner-freebsd-hackers Mon Mar 6 6:27: 6 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id A304837BD51 for ; Mon, 6 Mar 2000 06:26:56 -0800 (PST) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id IAA09021; Mon, 6 Mar 2000 08:44:06 -0500 (EST) Date: Mon, 6 Mar 2000 08:44:06 -0500 (EST) From: Daniel Eischen Message-Id: <200003061344.IAA09021@pcnet1.pcnet.com> To: freebsd-hackers@FreeBSD.ORG, tboxberg@schuett-elektronik.de Subject: Re: Pthread blocking I/O Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I use two threads to do I/O for a process. > The I/O takes place either on a socket or > an I/O device (com port) file descriptor. > > Apparently it is not possible to shutdown those > threads from a third thread, neither using close nor shutdown(2) for > the socket I/O if the threads are blocked during read. > > What methods can one use to unblock such a blocked-on-read > thread? The current implementation of FreeBSD pthreads only grants access to file descriptors to one thread at a time. I think if one thread tries to close a file descriptor from which another thread is reading, that the thread trying to close will block until the read completes. You can use pthread_kill() or pthread_cancel(). pthread_kill() should unblock the thread in a read state and return -1 with errno = EINTR. There were some bugs with signal handling that were fixed in -stable, so make sure you are running a relatively recent version. Dan Eischen eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message