From owner-freebsd-hackers Mon Feb 26 12:58:46 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from akira.lanfear.com (akira.lanfear.com [208.12.11.174]) by hub.freebsd.org (Postfix) with ESMTP id 5854737B491 for ; Mon, 26 Feb 2001 12:58:37 -0800 (PST) (envelope-from mwlist@lanfear.com) Received: from sapporo.lanfear.com (h-64-105-36-216.snvacaid.covad.net [64.105.36.216]) by akira.lanfear.com (8.9.3/8.9.3) with SMTP id MAA39013 for freebsd-hackers@freebsd.org; Mon, 26 Feb 2001 12:58:36 -0800 (PST) (envelope-from mwlist@lanfear.com) Date: Mon, 26 Feb 2001 12:58:36 -0800 (PST) From: Marc W Message-Id: <200102262058.MAA39013@akira.lanfear.com> To: freebsd-hackers@freebsd.org Subject: Why does a named pipe (FIFO) give me my data twice ??? MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Mailer: Kiltdown 0.7 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG hello! I've got a program that creates a named pipe, and then spawns a thread which sits in a loop: // error checking snipped. // while (1) { int fifo = open(fifoPath, O_RDONLY); // this blocks fprintf(stderr, "somebody opened the other end!\n"); read(fifo, buf, sizeof(buf)); fprintf(stderr, "got the following data: %s\n", buf); close(fifo); } i then have another instance of the same program do the following: fifo = open(fifoPath, O_WRONLY); write(fifo, buf, strlen(buf); now, the problem is that the first process succeeds suddenly for the open, reads the data, closes the fifo, and IMMEDIATELY SUCCEEDS THE open(2) again, reading in the same data. After that, all is as expected. Note that this doesn't happen ALL the time -- only about 80% of the time. Any idea why this would happen? Thanks! marc. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message