From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 22 15:00:57 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 16DF316A4CF for ; Mon, 22 Nov 2004 15:00:57 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E139943D4C for ; Mon, 22 Nov 2004 15:00:56 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id iAMF0sRs053279 for ; Mon, 22 Nov 2004 15:00:54 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id iAMF0sFV053273; Mon, 22 Nov 2004 15:00:54 GMT (envelope-from gnats) Resent-Date: Mon, 22 Nov 2004 15:00:54 GMT Resent-Message-Id: <200411221500.iAMF0sFV053273@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Derek Tattersall Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5909716A4CE for ; Mon, 22 Nov 2004 14:56:04 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 238DD43D54 for ; Mon, 22 Nov 2004 14:56:04 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id iAMEu3Ko037229 for ; Mon, 22 Nov 2004 14:56:03 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id iAMEu3Qo037228; Mon, 22 Nov 2004 14:56:03 GMT (envelope-from nobody) Message-Id: <200411221456.iAMEu3Qo037228@www.freebsd.org> Date: Mon, 22 Nov 2004 14:56:03 GMT From: Derek Tattersall To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: kern/74242: Write to fifo with no reader fails in 6.0 current X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2004 15:00:57 -0000 >Number: 74242 >Category: kern >Synopsis: Write to fifo with no reader fails in 6.0 current >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Nov 22 15:00:54 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Derek Tattersall >Release: 6.0 - 21 November 2004 >Organization: >Environment: FreeBSD lorne.arm.org 6.0-CURRENT FreeBSD 6.0-CURRENT #1: Sun Nov 21 12:00:32 EST 2004 root@lorne.arm.org:/usr/obj/usr/src/sys/LORNE i386 >Description: Problem: Writing to a fifo before a reader is present results in the write returning -1 with errno 45 "operation not supported". This behavior is new with a system cvsup'ed yesterday. ($?=0)dlt@lorne 1021 dlt% uname -a FreeBSD lorne.arm.org 6.0-CURRENT FreeBSD 6.0-CURRENT #1: Sun Nov 21 12:00:32 EST 2004 root@lorne.arm.org:/usr/obj/usr/src/sys/LORNE i386 The following two programs, speak.c (writer) and tick.c (reader) demonstrate the problem. If speak is started before tick, the write always fails. If tick is started before speak, everything works as expected. This code is slightly modified from code on Beej's Unix IPC site. speak.c -------------------------------------------------------------- #include #include #include #include #include #include #include #include #define FIFO_NAME "american_maid" main() { char s[300]; int num, fd; /* don't forget to error check this stuff!! */ /*mknod(FIFO_NAME, S_IFIFO | 0666, 0);*/ mkfifo(FIFO_NAME, 0666); printf("waiting for readers...\n"); fd = open(FIFO_NAME, O_WRONLY); printf("got a reader--type some stuff\n"); while (gets(s), !feof(stdin)) { if ((num = write(fd, s, strlen(s))) == -1) perror("write"); else printf("speak: wrote %d bytes\n", num); } } speak.c------------------------------------------------------------- tick.c ------------------------------------------------------------- #include #include #include #include #include #include #include #include #define FIFO_NAME "american_maid" main() { char s[300]; int num, fd; /* don't forget to error check this stuff!! */ mknod(FIFO_NAME, S_IFIFO | 0666, 0); printf("waiting for writers...\n"); fd = open(FIFO_NAME, O_RDONLY); printf("got a writer:\n"); do { if ((num = read(fd, s, 300)) == -1) perror("read"); else { s[num] = '\0'; printf("tick: read %d bytes: \"%s\"\n", num, s); } } while (num > 0); } tick.c------------------------------------------------------------- Note: On a 5.3 RELEASE system it does not matter which program is started first. In fact, this code has worked on current up through 11/10/2004. >How-To-Repeat: Using speak, compiled with "cc -o speak speak.c" and tick compiled with "cc -o tick tick.c", start speak in an xterm or console, then start tick in another xterm or console. Type in the speak window, mash newline, observe error message in speak window or console. Note that starting tick first then speak, and typing in the speak window shows no error. >Fix: >Release-Note: >Audit-Trail: >Unformatted: