diff options
| author | Florian Weimer <fweimer@redhat.com> | 2025-07-11 16:04:07 +0200 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2025-07-11 16:04:07 +0200 |
| commit | 02e7ac5ee3c6d2ef20c024ea7c243d0ae8496608 (patch) | |
| tree | 9968ec4c35283afb1304493a438374224c5ee5b1 /termios | |
| parent | c5687b4c49a91c5d9826959da2edcc7cdeec1273 (diff) | |
termios: Move isatty, __isatty_nostatus from io
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
The definition may depend on termios internals.
Diffstat (limited to 'termios')
| -rw-r--r-- | termios/Makefile | 2 | ||||
| -rw-r--r-- | termios/Versions | 3 | ||||
| -rw-r--r-- | termios/isatty.c | 31 | ||||
| -rw-r--r-- | termios/isatty_nostatus.c | 29 |
4 files changed, 65 insertions, 0 deletions
diff --git a/termios/Makefile b/termios/Makefile index 3cbd8917ad..1e23608255 100644 --- a/termios/Makefile +++ b/termios/Makefile @@ -36,6 +36,8 @@ routines := \ cfmakeraw \ cfsetbaud \ cfsetspeed \ + isatty \ + isatty_nostatus \ speed \ tcdrain \ tcflow \ diff --git a/termios/Versions b/termios/Versions index a5eec83257..03e2063b1f 100644 --- a/termios/Versions +++ b/termios/Versions @@ -3,6 +3,9 @@ libc { # c* cfgetispeed; cfgetospeed; cfmakeraw; cfsetispeed; cfsetospeed; cfsetspeed; + # i* + isatty; + # t* tcdrain; tcflow; tcflush; tcgetattr; tcgetpgrp; tcsendbreak; tcsetattr; tcsetpgrp; diff --git a/termios/isatty.c b/termios/isatty.c new file mode 100644 index 0000000000..3f3912d8e5 --- /dev/null +++ b/termios/isatty.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1991-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <unistd.h> + +/* Return 1 if FD is a terminal, 0 if not. */ +int +__isatty (int fd) +{ + __set_errno (ENOSYS); + return -1; +} + +weak_alias (__isatty, isatty) + +stub_warning (isatty) diff --git a/termios/isatty_nostatus.c b/termios/isatty_nostatus.c new file mode 100644 index 0000000000..e8ee796f3b --- /dev/null +++ b/termios/isatty_nostatus.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1991-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <unistd.h> + +/* Return 1 if FD is a terminal, 0 if not, without changing errno */ +int +__isatty_nostatus (int fd) +{ + int save_errno = errno; + int res = __isatty (fd); + __set_errno (save_errno); + return res; +} |
