From: Boyd Roberts <boyd@strakt.com>
To: "9fans@cse.psu.edu" <9fans@cse.psu.edu>
Subject: [9fans] isatty
Date: Wed, 23 Jan 2002 12:56:44 +0100 [thread overview]
Message-ID: <3C4EA4FC.A777CA4D@strakt.com> (raw)
Given I had to implement this 'thing' on Plan 9 I decided on:
#include <u.h>
#include <libc.h>
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].
next reply other threads:[~2002-01-23 11:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-23 11:56 Boyd Roberts [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-01-23 15:26 Russ Cox
2002-01-23 13:13 presotto
2002-01-23 13:43 ` Boyd Roberts
2001-02-14 15:45 rog
2001-02-14 15:09 Yehuda Tiram
[not found] <rob@plan9.bell-labs.com>
2001-02-14 13:51 ` rob pike
2001-02-14 16:42 ` Scott Schwartz
2001-02-14 13:48 rog
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C4EA4FC.A777CA4D@strakt.com \
--to=boyd@strakt.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).