Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Implement tcgetwinsize() and tcsetwinsize() in libc, with ac...
details: https://anonhg.NetBSD.org/src/rev/04a6da3adda0
branches: trunk
changeset: 357062:04a6da3adda0
user: kre <kre%NetBSD.org@localhost>
date: Wed Oct 25 06:32:59 2017 +0000
description:
Implement tcgetwinsize() and tcsetwinsize() in libc, with access
via <termios.h> (and document them.) Bump libc minor number for them.
Arrange for "struct winsize" to become visible in <termios.h>
Fix stty(1) so that "cols" is reported as the arg to set number of columns,
and "columns" is the alias, rather than the other way around, as "cols" is
what has been added to POSIX.
This is to conform with updates to be included in 1003.1 issue 8
(whenever that gets published) currently available at:
http://austingroupbugs.net/view.php?id=1053 (see note 3863)
http://austingroupbugs.net/view.php?id=1151 (see note 3856)
diffstat:
bin/stty/stty.1 | 8 +-
distrib/sets/lists/base/shl.mi | 6 +-
distrib/sets/lists/comp/mi | 8 +-
distrib/sets/lists/debug/shl.mi | 6 +-
lib/libc/shlib_version | 4 +-
lib/libc/termios/Makefile.inc | 9 +-
lib/libc/termios/tcgetwinsize.3 | 217 ++++++++++++++++++++++++++++++++++++++++
lib/libc/termios/tcgetwinsize.c | 48 ++++++++
lib/libc/termios/tcsetwinsize.c | 48 ++++++++
sys/sys/termios.h | 12 +-
sys/sys/ttycom.h | 21 +++-
11 files changed, 362 insertions(+), 25 deletions(-)
diffs (truncated from 561 to 300 lines):
diff -r 5fcb1999e109 -r 04a6da3adda0 bin/stty/stty.1
--- a/bin/stty/stty.1 Wed Oct 25 06:02:40 2017 +0000
+++ b/bin/stty/stty.1 Wed Oct 25 06:32:59 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: stty.1,v 1.43 2016/08/14 23:29:43 sevan Exp $
+.\" $NetBSD: stty.1,v 1.44 2017/10/25 06:32:59 kre Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -477,13 +477,13 @@
system load average, the current command name, its process ID, the
event the process is waiting on (or the status of the process), the user
and system times, percent CPU, and current memory usage.
-.It Cm columns Ar number
+.It Cm cols Ar number
The terminal size is recorded as having
.Ar number
columns.
-.It Cm cols Ar number
+.It Cm columns Ar number
An alias for
-.Cm columns .
+.Cm cols .
.It Cm rows Ar number
The terminal size is recorded as having
.Ar number
diff -r 5fcb1999e109 -r 04a6da3adda0 distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Wed Oct 25 06:02:40 2017 +0000
+++ b/distrib/sets/lists/base/shl.mi Wed Oct 25 06:32:59 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.823 2017/10/10 19:31:56 christos Exp $
+# $NetBSD: shl.mi,v 1.824 2017/10/25 06:32:59 kre Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -18,7 +18,7 @@
./lib/libblacklist.so.0.0 base-sys-shlib dynamicroot
./lib/libc.so base-sys-shlib dynamicroot
./lib/libc.so.12 base-sys-shlib dynamicroot
-./lib/libc.so.12.208 base-sys-shlib dynamicroot
+./lib/libc.so.12.209 base-sys-shlib dynamicroot
./lib/libcrypt.so base-sys-shlib dynamicroot
./lib/libcrypt.so.1 base-sys-shlib dynamicroot
./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot
@@ -217,7 +217,7 @@
./usr/lib/libc++.so.1.0 base-sys-shlib compatfile,libcxx
./usr/lib/libc.so base-sys-shlib compatfile
./usr/lib/libc.so.12 base-sys-shlib compatfile
-./usr/lib/libc.so.12.208 base-sys-shlib compatfile
+./usr/lib/libc.so.12.209 base-sys-shlib compatfile
./usr/lib/libcdk.so base-obsolete compatfile,obsolete
./usr/lib/libcom_err.so base-krb5-shlib compatfile,kerberos
./usr/lib/libcom_err.so.8 base-krb5-shlib compatfile,kerberos
diff -r 5fcb1999e109 -r 04a6da3adda0 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Wed Oct 25 06:02:40 2017 +0000
+++ b/distrib/sets/lists/comp/mi Wed Oct 25 06:32:59 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2152 2017/10/16 11:38:25 maya Exp $
+# $NetBSD: mi,v 1.2153 2017/10/25 06:32:59 kre Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -9570,9 +9570,11 @@
./usr/share/man/cat3/tcgetattr.0 comp-c-catman .cat
./usr/share/man/cat3/tcgetpgrp.0 comp-c-catman .cat
./usr/share/man/cat3/tcgetsid.0 comp-c-catman .cat
+./usr/share/man/cat3/tcgetwinsize.0 comp-c-catman .cat
./usr/share/man/cat3/tcsendbreak.0 comp-c-catman .cat
./usr/share/man/cat3/tcsetattr.0 comp-c-catman .cat
./usr/share/man/cat3/tcsetpgrp.0 comp-c-catman .cat
+./usr/share/man/cat3/tcsetwinsize.0 comp-c-catman .cat
./usr/share/man/cat3/td_close.0 comp-obsolete obsolete
./usr/share/man/cat3/td_map_pth2thr.0 comp-obsolete obsolete
./usr/share/man/cat3/td_open.0 comp-obsolete obsolete
@@ -17081,9 +17083,11 @@
./usr/share/man/html3/tcgetattr.html comp-c-htmlman html
./usr/share/man/html3/tcgetpgrp.html comp-c-htmlman html
./usr/share/man/html3/tcgetsid.html comp-c-htmlman html
+./usr/share/man/html3/tcgetwinsize.html comp-c-htmlman html
./usr/share/man/html3/tcsendbreak.html comp-c-htmlman html
./usr/share/man/html3/tcsetattr.html comp-c-htmlman html
./usr/share/man/html3/tcsetpgrp.html comp-c-htmlman html
+./usr/share/man/html3/tcsetwinsize.html comp-c-htmlman html
./usr/share/man/html3/td_close.html comp-obsolete obsolete
./usr/share/man/html3/td_map_pth2thr.html comp-obsolete obsolete
./usr/share/man/html3/td_open.html comp-obsolete obsolete
@@ -24653,9 +24657,11 @@
./usr/share/man/man3/tcgetattr.3 comp-c-man .man
./usr/share/man/man3/tcgetpgrp.3 comp-c-man .man
./usr/share/man/man3/tcgetsid.3 comp-c-man .man
+./usr/share/man/man3/tcgetwinsize.3 comp-c-man .man
./usr/share/man/man3/tcsendbreak.3 comp-c-man .man
./usr/share/man/man3/tcsetattr.3 comp-c-man .man
./usr/share/man/man3/tcsetpgrp.3 comp-c-man .man
+./usr/share/man/man3/tcsetwinsize.3 comp-c-man .man
./usr/share/man/man3/td_close.3 comp-obsolete obsolete
./usr/share/man/man3/td_map_pth2thr.3 comp-obsolete obsolete
./usr/share/man/man3/td_open.3 comp-obsolete obsolete
diff -r 5fcb1999e109 -r 04a6da3adda0 distrib/sets/lists/debug/shl.mi
--- a/distrib/sets/lists/debug/shl.mi Wed Oct 25 06:02:40 2017 +0000
+++ b/distrib/sets/lists/debug/shl.mi Wed Oct 25 06:32:59 2017 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: shl.mi,v 1.185 2017/10/10 19:31:57 christos Exp $
+# $NetBSD: shl.mi,v 1.186 2017/10/25 06:32:59 kre Exp $
./usr/lib/libbfd_g.a comp-c-debuglib debuglib,compatfile,binutils
./usr/libdata/debug/lib base-sys-usr debug,dynamicroot,compatdir
./usr/libdata/debug/lib/libblacklist.so.0.0.debug comp-sys-debug debug,dynamicroot
-./usr/libdata/debug/lib/libc.so.12.208.debug comp-sys-debug debug,dynamicroot
+./usr/libdata/debug/lib/libc.so.12.209.debug comp-sys-debug debug,dynamicroot
./usr/libdata/debug/lib/libcrypt.so.1.0.debug comp-sys-debug debug,dynamicroot
./usr/libdata/debug/lib/libcrypto.so.12.0.debug comp-sys-debug debug,dynamicroot
./usr/libdata/debug/lib/libdevmapper.so.1.0.debug comp-sys-debug debug,dynamicroot,lvm
@@ -70,7 +70,7 @@
./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compatfile
./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug,compatfile
./usr/libdata/debug/usr/lib/libc++.so.1.0.debug comp-sys-debug debug,compatfile,libcxx
-./usr/libdata/debug/usr/lib/libc.so.12.208.debug comp-sys-debug debug,compatfile
+./usr/libdata/debug/usr/lib/libc.so.12.209.debug comp-sys-debug debug,compatfile
./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug comp-krb5-debug debug,compatfile,kerberos
./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug,compatfile
./usr/libdata/debug/usr/lib/libcrypto.so.12.0.debug comp-crypto-debug debug,compatfile
diff -r 5fcb1999e109 -r 04a6da3adda0 lib/libc/shlib_version
--- a/lib/libc/shlib_version Wed Oct 25 06:02:40 2017 +0000
+++ b/lib/libc/shlib_version Wed Oct 25 06:32:59 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shlib_version,v 1.277 2017/10/05 04:38:08 dholland Exp $
+# $NetBSD: shlib_version,v 1.278 2017/10/25 06:32:59 kre Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@@ -52,4 +52,4 @@
# - clean-up initialisation order between crt0.o, rtld and libc.
# - move environ and __ps_strings from crt0.o into libc.
major=12
-minor=208
+minor=209
diff -r 5fcb1999e109 -r 04a6da3adda0 lib/libc/termios/Makefile.inc
--- a/lib/libc/termios/Makefile.inc Wed Oct 25 06:02:40 2017 +0000
+++ b/lib/libc/termios/Makefile.inc Wed Oct 25 06:32:59 2017 +0000
@@ -1,13 +1,16 @@
-# $NetBSD: Makefile.inc,v 1.4 1998/02/14 20:20:44 kleink Exp $
+# $NetBSD: Makefile.inc,v 1.5 2017/10/25 06:32:59 kre Exp $
.PATH: ${.CURDIR}/termios
SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
- tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c
+ tcgetwinsize.c tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c \
+ tcsetwinsize.c
-MAN+= tcgetpgrp.3 tcgetsid.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3
+MAN+= tcgetpgrp.3 tcgetsid.3 tcgetwinsize.3 tcsendbreak.3 tcsetattr.3 \
+ tcsetpgrp.3
+MLINKS+=tcgetwinsize.3 tcsetwinsize.3
MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 \
tcsendbreak.3 tcflush.3
MLINKS+=tcsetattr.3 tcgetattr.3 tcsetattr.3 cfgetispeed.3 \
diff -r 5fcb1999e109 -r 04a6da3adda0 lib/libc/termios/tcgetwinsize.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/termios/tcgetwinsize.3 Wed Oct 25 06:32:59 2017 +0000
@@ -0,0 +1,217 @@
+.\" $NetBSD: tcgetwinsize.3,v 1.1 2017/10/25 06:32:59 kre Exp $
+.\"
+.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd October 25, 2017
+.Dt TCGETWINSIZE 3
+.Os
+.Sh NAME
+.Nm tcgetwinsize ,
+.Nm tcsetwinsize
+.Nd manipulate terminal window size
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In termios.h
+.Fd
+.Ft int
+.Fn tcgetwinsize "int fd" "struct winsize *gws"
+.Fd
+.Ft int
+.Fn tcsetwinsize "int fd" "const struct winsize *sws"
+.Sh DESCRIPTION
+The
+.Nm tcgetwinsize
+function fills in the
+.Ic winsize
+structure pointed to by
+.Fa gws
+with values that represent the size of the
+terminal window for which
+.Fa fd
+provides an open file descriptor.
+If no error occurs
+.Fn tcgetwinsize
+returns zero (0).
+.Pp
+The
+.Nm tcsetwinsize
+function sets the terminal window size,
+for the terminal referenced by
+.Fa fd ,
+to the sizes from the
+.Ic winsize
+structure pointed to by
+.Fa sws .
+If no error occurs
+.Fn tcsetwinsize
+returns zero (0).
+.Pp
+The
+.Ic winsize
+structure, defined in
+.In termios.h ,
+contains (at least) the following four fields
+.Bd -literal
+ unsigned short ws_row; /* Number of rows, in characters */
+ unsigned short ws_col; /* Number of columns, in characters */
+ unsigned short ws_xpixel; /* Width, in pixels */
+ unsigned short ws_ypixel; /* Height, in pixels */
+.Ed
+.Pp
+If the actual window size of the controlling terminal
+of a process changes, the process is sent a
+.Dv SIGWINCH
+signal.
+See
+.Xr signal 7 .
+Note simply changing the sizes using
+.Fn tcsetwinsize
+does not necessarily change the actual window size,
+and if not, will not generate a
+.Dv SIGWINCH .
+.Sh ERRORS
+If an error occurs,
+.Fn tcgetwinsize
+and
+.Fn tcsetwinsize
+return -1 and cause the global variable
+.Va errno
+to be set to indicate the error.
+Common errors are as follows:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument to
+.Fn tcgetwinsize
+or
+.Fn tcsetwinsize
+is not a valid file descriptor.
+.It Bq Er EFAULT
+The
+.Fa gws
+argument to
+.Fn tcgetwinsize
+does not point to a suitable location
+into which to store the resulting
+.Ic winsize
+structure,
+or the
+.Fa sws
+argument to
+.Fn tcsetwinsize
+does not refer to a suitable location
+from which the
+.Ic winsize
+structure can be obtained.
+.It Bq Er EINVAL
+The values passed in the
+.Ar sws
+.Ic winsize
+structure to
+.Fn tcsetwinsize
+represent an attempt to set the window size to an invalid state.
+.It Bq Er ENOTTY
Home |
Main Index |
Thread Index |
Old Index