Created attachment 220579 [details]
Patches for adding tcgetwinsize() and tcsetwinsize() functions that are now available in NetBSD and are expected to be a part of POSIX.1 issue 8. These functions get/set tty winsize respectively. Please see https://www.austingroupbugs.net/view.php?id=1151#c3856.
If these patches are accepted, then please add a comment to remind me to supply my preferred email address. The Bugzilla account email address is unsuitable for a commit. Thank you.
Created attachment 220580 [details]
Created attachment 220581 [details]
Your test program cannot link with your patch. termios.h changes, esp. the move of headers, are wrong.
Created attachment 220607 [details]
Sir, thank you for notifying me about this. I have now restored the order in termios.h. Additionally, I have #include-d <sys/ioctl.h>; we need it for struct winsize. According to the POSIX proposal, the tcgetwinsize() and tcsetwinsize() declarations need to be in termios.h.
I left termios.c.diff and the test program unchanged. Please let me know if there are any more problems.
sys/ioctl.h must not be included into posix header, it contaminates user namespace.
You test program still cannot link.
Use phabricator to submit patches, https://reviews.freebsd.org
Sir, I have created a phabricator account. Can you please approve it? The email address is the same as that of this Bugzilla account.
I have made an observation. Both the NetBSD and the OpenBSD versions of termios.h only have sys/ttydefaults.h in the last block after the #endif /* !_TERMIOS_H_ */:
glibc does something similar: https://github.com/bminor/glibc/blob/master/termios/termios.h although their sys/ttydefaults.h is being included in the protected block.
FreeBSD's termios.h was changed from https://svnweb.freebsd.org/base/head/include/termios.h?revision=191882&view=markup to https://svnweb.freebsd.org/base/head/include/termios.h?revision=199898&view=markup when ttycom.h suddenly got moved to the last block; there is no explanation in the SVN "commit message" as to why that was done. I suspect that it was a mistake.
If you think that my claim is correct, then I will replace the #include <sys/ioctl.h> in my diff with a #include <sys/ttycom.h> and remove the #include <sys/ttycom.h> from the final block; sys/ttycom.h contains the definition of struct winsize needed for tcgetwinsize() and tcsetwinsize(). Basically, then it will look like the NetBSD header: https://github.com/NetBSD/src/blob/trunk/sys/sys/termios.h
Thank you for your time.
Created attachment 220616 [details]
I updated termios.h.diff to demonstrate what I was proposing in my last comment. There is no need to test it; I have not tested the patches on phabricator yet. Thank you.
Created attachment 220654 [details]
Added the Symbol.map file. It should now link after rebuilding libc. I will now also submit this patch to phabricator.
The patches here are now outdated. New patches are on phabricator.
A commit in branch main references this bug:
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2020-12-24 23:05:31 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2020-12-25 18:43:09 +0000
Add tcgetwinsize(3) and tcsetwinsize(3) to termios
These functions get/set tty winsize respectively, and are trivial wrappers
around corresponding termio ioctls.
The functions are expected to be a part of POSIX.1 issue 8:
They are currently available in NetBSD and in musl libc.
Submitted by: Soumendra Ganguly <firstname.lastname@example.org>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27650
include/termios.h | 6 ++++++
lib/libc/gen/Symbol.map | 2 ++
lib/libc/gen/termios.c | 14 ++++++++++++++
sys/sys/_winsize.h (new) | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
sys/sys/ttycom.h | 12 +-----------
5 files changed, 72 insertions(+), 11 deletions(-)
In https://reviews.freebsd.org/D27650, I had written: "OTOH, while it's not a big deal anymore, I wonder why some of the other platforms such as NetBSD have chosen to not put the winsize materials under _NETBSD_SOURCE."
Here lies the answer to the question: https://mail-index.netbsd.org/tech-userlevel/2017/10/21/msg010899.html
Basically, Christos Zoulas cleverly avoided the namespace contamination by letting sys/ttycom.h only make visible struct winsize when _NETBSD_SOURCE is not defined: https://github.com/NetBSD/src/blob/trunk/sys/sys/ttycom.h
My OCD is now satisfied.
I have created a new differential revision for the manpage: https://reviews.freebsd.org/D27787
Note that for full implementation of POSIX issue 1151, the sys/signal.h header will need to be changed to expose SIGWINCH even when _BSD_VISIBLE is not defined. While probably too late for 13.0, this change is needed at some point.
(In reply to Robert Clausecker from comment #17)
To implement this change, we need a released POSIX version.