source: trunk/libs/newlib/src/libgloss/epiphany/_isatty.c @ 470

Last change on this file since 470 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.0 KB
Line 
1/* isatty.c
2
3   Copyright (c) 1994-2009  Red Hat, Inc. All rights reserved.
4   Copyright (c) 2012 Adapteva, Inc.
5
6   This copyrighted material is made available to anyone wishing to use,
7   modify, copy, or redistribute it subject to the terms and conditions
8   of the BSD License.   This program is distributed in the hope that
9   it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
10   including the implied warranties of MERCHANTABILITY or FITNESS FOR
11   A PARTICULAR PURPOSE.  A copy of this license is available at
12   http://www.opensource.org/licenses. Any Red Hat trademarks that are
13   incorporated in the source code or documentation are not subject to
14   the BSD License and may only be used or replicated with the express
15   permission of Red Hat, Inc.  */
16
17/* Dumb implementation so programs will at least run.  */
18
19#include <sys/stat.h>
20#include <errno.h>
21
22int
23_isatty (int fd)
24{
25  struct stat buf;
26
27  if (_fstat (fd, &buf) < 0) {
28    errno = EBADF;
29    return 0;
30  }
31  if (S_ISCHR (buf.st_mode))
32    return 1;
33  errno = ENOTTY;
34  return 0;
35}
Note: See TracBrowser for help on using the repository browser.