From owner-freebsd-questions Tue Jul 31 12:23:24 2001 Delivered-To: freebsd-questions@freebsd.org Received: from beta.root-servers.ch (gamma.root-servers.ch [195.49.62.126]) by hub.freebsd.org (Postfix) with SMTP id B07D137B401 for ; Tue, 31 Jul 2001 12:23:19 -0700 (PDT) (envelope-from gabriel_ambuehl@buz.ch) Received: (qmail 30406 invoked from network); 31 Jul 2001 19:23:17 -0000 Received: from unknown (HELO athlon550) (62.2.99.98) by beta.root-servers.ch with SMTP; 31 Jul 2001 19:23:17 -0000 Date: Tue, 31 Jul 2001 21:24:48 +0200 From: Gabriel Ambuehl X-Mailer: The Bat! (v1.53bis) Educational Organization: BUZ Internet Services X-Priority: 3 (Normal) Message-ID: <115350818950.20010731212448@buz.ch> To: questions@freebsd.org Subject: select() on a named pipe blocks indefinitely MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 -----BEGIN PGP SIGNED MESSAGE----- Hello, 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. But without select(), I see all the data I cat > FIFO_PATH into the named pipe... { 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); //blocks if there's no writer on the pipe but as soon as one //opens the pipe, it will return as it should. According to UNPv2 //this is the correct behavior. if (fifo_des < 0) { cout << "fatal error: can't open FIFO" << endl; exit(1); } FD_ZERO(&rset); while(1) { FD_SET(fifo_des, &rset); select(1, &rset, (fd_set *) NULL, (fd_set *) NULL, (struct timeval *) NULL); if(FD_ISSET(fifo_des, &rset)) { read(fifo_des, (void *) &result, (size_t) sizeof(result)); cout << "message: " << result <