tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: FYI: POSIX update - SIGWINCH and 'struct winsize' (etc) to be added



In article <29379.1508551060%andromeda.noi.kre.to@localhost>,
Robert Elz  <kre%munnari.OZ.AU@localhost> wrote:
>Updates (should appear in issue 8 of the std) have been approved,
>as resolutions to bug reports 1053 (stty) and 1151 (the rest),
>which add (in ways compatible with what we already have):
>
>	SIGWINCH
>	struct winsize
>	stty size, stty rows N, stty cols N
>
>Since struct winsize is manipulated via ioctl, and ioctl is not POSIX,
>it also adds 2 functions that we don't have
>
>	tcgetwinsize()
>	tcsetwinsize()
>
>Theses were originally to be called tcgetsize() and tcsetsize() which
>several other systems already provide, until it was discovered that there
>are systems (well, one known) that have functions with those names but
>with a different signature (what the difference is, I have no idea, nor
>does it matter.)
>
>SIGWINCH goes in <signal.h> where we have it (from <sys/signal.h> like
>all the others).  The stty changes are no different than what we have
>(it is permitted to include the size info in -g output, but not required,
>applications are supposed to save/restore the size using
>
>	ttysize=$(printf "rows %d cols %d" $(stty size))		# to save
>
>	stty $ttysize						# to restore
>
>(obviously other equiv formulations are also OK.)
>
>The rest of the new stuff belongs to <termios.h>
>
>Actions that will be needed as I see it are
>
>	1.  Move struct winsize from <sys/ttycom.h> to <termios.h>
>	    which probably means moving it to a new <sys/xxxx.h> and
>	    including it from both <termios.h> (outside the _NETBSD_SOURCE
>	    section which already includes <sys/ttycom.h>) and from
>	    <sys/ttycom.h> for backward compat (incl to avoid needing to
>	    adjust other kernel sources.)

That is <sys/termios.h> already; termios.h is a symlink to that.
Try to move it there. I doubt it will cause any disruption. We might
be able to save creating another header.

>	2.  Add the 2 new functions to src/lib/libc/termios and their
>	    prototypes to <termios.h>
>
>	3.  Change the man page stty(1) to make "cols" appear as the
>	    actual arg, and "columns" the alias .... (highly crucial that one!)
>
>The proposed "struct winsize" is only required to contain ws_row and ws_col
>but they are defined so that other fields (like ws_xpixel and ws_ypixel,
>which everyone has, can remain).
>
>The signatures for the new functions (for <termios.h>) are:
>
>    int tcgetwinsize(int, struct winsize *);
>    int tcsetwinsize(int, const struct winsize *);
>
>They do the obvious (simply perform the ioctl, the int is "fd")
>They both return 0 (OK) or -1 (error, with errno set) - ie: exactly
>what the ioctl returns (they could almost be defined as macros...
>but not, as then we'd have to expose the ioctl names to non NETBSD_SOURCE
>code.)
>
>The final text for the 2 resolutions is in:
>
>	note 3863 of: http://austingroupbugs.net/view.php?id=1053   (stty)
>	note 3856 of: http://austingroupbugs.net/view.php?id=1151   (the rest)
>
>kre
>
>ps: Issue 8 is still some time away - definitely not this year, quite
>likely not next...   so this is not urgent, but getting it done to include
>in NetBSD 8 would not hurt, Issue8 is likely to appear during NetBSD 8's
>lifetime.

Sounds straight-forward enough.

christos




Home | Main Index | Thread Index | Old Index