Date: Tue, 10 Sep 2002 09:56:19 -0700 (PDT) From: Archie Cobbs <archie@dellroad.org> To: freebsd-arch@freebsd.org Subject: /dev/stdout behavior Message-ID: <200209101656.g8AGuJ433605@arch20m.dellroad.org>
next in thread | raw e-mail | index | archive | help
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 <stdio.h> #include <fcntl.h> #include <err.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209101656.g8AGuJ433605>