From owner-freebsd-arch Tue Sep 10 10: 0: 6 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D411C37B400 for ; Tue, 10 Sep 2002 10:00:03 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 35FE243E65 for ; Tue, 10 Sep 2002 10:00:03 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id JAA60557 for ; Tue, 10 Sep 2002 09:58:01 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g8AGuJ433605 for freebsd-arch@freebsd.org; Tue, 10 Sep 2002 09:56:19 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200209101656.g8AGuJ433605@arch20m.dellroad.org> Subject: /dev/stdout behavior To: freebsd-arch@freebsd.org Date: Tue, 10 Sep 2002 09:56:19 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Is there an 'official' spec about how /dev/stdout is supposed to behave? For example, if you use fcntl() to set flags on fd 0, and then open /dev/stdout, the new file descriptor you get back will have those same flags set. Run the program below to see an example. This is in agreement with the man page, which states that opening /dev/stdout is equivalent to dup(2)'ing fd 0. However, on RedHat Linux 7.3, the program below behaves in the opposite manner from FreeBSD, i.e., it prints "O_NONBLOCK is not set". So at least one of FreeBSD or Linux is 'wrong' about /dev/stdout, or maybe there is no general agreement about what /dev/stdout means.. ? Thanks, -Archie P.S. This issue underlies PR misc/41331: http://www.freebsd.org/cgi/query-pr.cgi?pr=41331 __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com #include #include #include int main(int argc, char **argv) { int flags; int fd; if ((flags = fcntl(0, F_GETFL, 0)) == -1) err(1, "fcntl"); if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) err(1, "fcntl"); if ((fd = open("/dev/stdout", O_WRONLY, 0)) == -1) err(1, "open"); if ((flags = fcntl(fd, F_GETFL, 0)) == -1) err(1, "fcntl"); printf("O_NONBLOCK is %s\n", (flags & O_NONBLOCK) ? "set" : "not set"); return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message