2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: getBufferMode.c,v 1.1 1998/04/10 10:54:33 simonm Exp $
6 * hIs...Buffered Runtime Support
12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
16 #ifdef HAVE_SYS_STAT_H
21 * We try to guess what the default buffer mode is going to be based
22 * on the type of file we're attached to.
31 getBufferMode(StgAddr fp)
35 /* Try to find out the file type */
36 while (fstat(fileno((FILE *) fp), &sb) < 0) {
44 /* Terminals are line-buffered by default */
45 if (S_ISCHR(sb.st_mode) && isatty(fileno((FILE *) fp)) == 1)
47 /* Default size block buffering for the others */