aboutsummaryrefslogtreecommitdiffstats
path: root/posix/gawkmisc.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 13:14:38 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 13:14:38 +0300
commitfae4762eba9ff7bb466a600130e9c90eaac6b0bc (patch)
tree62711fe7cd511824b5f8a90ba1ba7b523d42e127 /posix/gawkmisc.c
parentbc70de7b3302d5a81515b901cae376b8b51d2004 (diff)
downloadegawk-fae4762eba9ff7bb466a600130e9c90eaac6b0bc.tar.gz
egawk-fae4762eba9ff7bb466a600130e9c90eaac6b0bc.tar.bz2
egawk-fae4762eba9ff7bb466a600130e9c90eaac6b0bc.zip
Move to gawk-3.1.1.
Diffstat (limited to 'posix/gawkmisc.c')
-rw-r--r--posix/gawkmisc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index 4f94683d..7f5e47ab 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -1,6 +1,6 @@
-/* gawkmisc.c --- miscellanious gawk routines that are OS specific.
+/* gawkmisc.c --- miscellaneous gawk routines that are OS specific.
- Copyright (C) 1986, 1988, 1989, 1991 - 98, 2001 the Free Software Foundation, Inc.
+ Copyright (C) 1986, 1988, 1989, 1991 - 1998, 2001, 2002 the Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -82,13 +82,10 @@ struct stat *stb;
#define DEFBLKSIZE BUFSIZ
#endif
- if (isatty(fd))
- return BUFSIZ;
if (fstat(fd, stb) == -1)
fatal("can't stat fd %d (%s)", fd, strerror(errno));
- if (lseek(fd, (off_t)0, 0) == -1) /* not a regular file */
- return DEFBLKSIZE;
- if (stb->st_size > 0 && stb->st_size < DEFBLKSIZE) /* small file */
+ if (S_ISREG(stb->st_mode)
+ && 0 < stb->st_size && stb->st_size < DEFBLKSIZE) /* small file */
return stb->st_size;
return DEFBLKSIZE;
}
@@ -118,8 +115,11 @@ os_close_on_exec(fd, name, what, dir)
int fd;
const char *name, *what, *dir;
{
+ if (fd <= 2) /* sanity */
+ return;
+
if (fcntl(fd, F_SETFD, 1) < 0)
- warning(_("%s %s `%s': could not set close-on-exec: %s"),
+ warning(_("%s %s `%s': could not set close-on-exec: (fcntl: %s)"),
what, dir, name, strerror(errno));
}