From owner-freebsd-questions Tue Jul 31 14:15: 8 2001 Delivered-To: freebsd-questions@freebsd.org Received: from comp04.prc.uic.edu (comp04.prc.uic.edu [128.248.230.104]) by hub.freebsd.org (Postfix) with SMTP id 017B237B403 for ; Tue, 31 Jul 2001 14:15:04 -0700 (PDT) (envelope-from lucas@comp04.prc.uic.edu) Received: (qmail 39859 invoked by uid 1000); 31 Jul 2001 21:14:59 -0000 Date: Tue, 31 Jul 2001 16:14:59 -0500 From: Lucas Bergman To: Gabriel Ambuehl Cc: questions@freebsd.org Subject: Re: select() on a named pipe blocks indefinitely Message-ID: <20010731161459.A38416@comp04.prc.uic.edu> Reply-To: iceberg@pobox.com References: <115350818950.20010731212448@buz.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <115350818950.20010731212448@buz.ch>; from gabriel_ambuehl@buz.ch on Tue, Jul 31, 2001 at 09:24:48PM +0200 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 > I've there got a strange problem with select on a named pipe (FIFO): > If I call select() on it without supplying a timeout, the program > won't ever return from the select until it's killed... Regarding your code: Please, in the future, include a small example like this that *compiles*. It is obnoxious to give something like this and rely on someone else to add the #include lines, the #define FIFO_PATH, the main() routine, etc. In this case, the error was blatant enough that I didn't have to compile your code. > { > char result[512]; > int fifo_des; > fd_set rset; > mkfifo(FIFO_PATH, (mode_t) (S_IRUSR | S_IWUSR | S_IWGRP)); > fifo_des=open((const char *) FIFO_PATH, O_RDONLY|O_NONBLOCK); > FD_ZERO(&rset); > while(1) > { > FD_SET(fifo_des, &rset); > select(1, &rset, (fd_set *) NULL, (fd_set *) NULL, (struct > timeval *) NULL); I think you mean select(fifo_des + 1, &rset, 0, 0, 0); Your first argument to select() is wrong; what you have will block forever even when data are available on fifo_des, provided fifo_des > 0. See select(2) for details. Lucas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message