rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* isatty() & rshd
@ 1991-09-26 15:06 Brendan Kehoe
  0 siblings, 0 replies; only message in thread
From: Brendan Kehoe @ 1991-09-26 15:06 UTC (permalink / raw)
  To: byron; +Cc: rc


I've recently started playing with rc (not on the mailing list yet,
could you please add me?), and I noticed one letter in the archives:

   From: Byron Rakitzis <byron>
   Date: Fri, 2 Aug 1991 12:12:50 -0500

   [Using isatty() for rshd use] has a couple of (minor)
   disadvantages, as I see it: at the moment, rc does not run isatty()
   when input is via -c. This is because on my Sun, isatty() takes a
   hideously long time to run (tenths of a second?).  Therefore, I'd
   like to run isatty() only when I have to.

If that's still a point of concern, here's a version of isatty() I
hacked together a while ago that seems to work for most cases (I
haven't found one where it doesn't yet).  Just to get past any
Sun-specific hurdles. :)

--
/* bk_isatty -- A really cheap version of isatty().
   by Brendan Kehoe (brendan@cs.widener.edu).  */

#include <sys/ioctl.h>

/* Return 1 if FD is a terminal, 0 if not.  */
int
bk_isatty (fd)
     int fd;
{
  static struct sgttyb buf;

  if (ioctl (fd, TIOCGETP, (char *) &buf) == 0)
    return 1; /* It's a TTY.  */

  return 0; /* It's not.  */
}
-- cut --
--
Brendan Kehoe, Sun Network Manager                      brendan@cs.widener.edu
Widener University                                                 Chester, PA


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1991-09-26 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-09-26 15:06 isatty() & rshd Brendan Kehoe

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).