From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3C4EA4FC.A777CA4D@strakt.com> From: Boyd Roberts MIME-Version: 1.0 To: "9fans@cse.psu.edu" <9fans@cse.psu.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: [9fans] isatty Date: Wed, 23 Jan 2002 12:56:44 +0100 Topicbox-Message-UUID: 41df06b0-eaca-11e9-9e20-41e7f4b1d025 Given I had to implement this 'thing' on Plan 9 I decided on: #include #include static char *cons = "/dev/cons"; /* * Compare fd to cons should get it right. */ int isatty(int fd) { Dir c; Dir f; if (dirstat(cons, &c) != 0) return 0; if (dirfstat(fd, &f) != 0) return 0; return f.type == c.type && f.dev == c.dev && f.qid.path == c.qid.path && f.qid.vers == c.qid.vers; } Seemed obvious to me, but is this a good plan? The overkill on the multiple dirstat's on /dev/cons and qid comparison I thought would ensure that I wouldn't get fooled [again].