mailing list of musl libc
 help / color / mirror / Atom feed
* [musl] POSIX & SIGWINCH
@ 2020-07-24 17:51 Rich Felker
  2020-08-19 23:09 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2020-07-24 17:51 UTC (permalink / raw)
  To: musl

Somehow I missed that POSIX has adopted (for future issue) SIGWINCH and
struct winsize and added functions (instead of raw ioctl) to get/set
window size:

https://www.austingroupbugs.net/view.php?id=1151#c3856

These should be added to musl. I'll aim to do this along with other
proposed additions shortly after release.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] POSIX & SIGWINCH
  2020-07-24 17:51 [musl] POSIX & SIGWINCH Rich Felker
@ 2020-08-19 23:09 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-08-19 23:09 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

On Fri, Jul 24, 2020 at 01:51:14PM -0400, Rich Felker wrote:
> Somehow I missed that POSIX has adopted (for future issue) SIGWINCH and
> struct winsize and added functions (instead of raw ioctl) to get/set
> window size:
> 
> https://www.austingroupbugs.net/view.php?id=1151#c3856
> 
> These should be added to musl. I'll aim to do this along with other
> proposed additions shortly after release.

Proposed patch attached. We should examine whether moving struct
winsize out of ioctl.h will break anything; if so ioctl.h could
include termios.h or we could put the struct in the shared alltypes.

Rich

[-- Attachment #2: winsize.diff --]
[-- Type: text/plain, Size: 1885 bytes --]

diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
index c2ce3b48..d6a7d474 100644
--- a/include/sys/ioctl.h
+++ b/include/sys/ioctl.h
@@ -47,13 +47,6 @@ extern "C" {
 
 #define TIOCSER_TEMT 1
 
-struct winsize {
-	unsigned short ws_row;
-	unsigned short ws_col;
-	unsigned short ws_xpixel;
-	unsigned short ws_ypixel;
-};
-
 #define SIOCADDRT          0x890B
 #define SIOCDELRT          0x890C
 #define SIOCRTMSG          0x890D
diff --git a/include/termios.h b/include/termios.h
index d73c780d..793cfc94 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -15,6 +15,13 @@ typedef unsigned char cc_t;
 typedef unsigned int speed_t;
 typedef unsigned int tcflag_t;
 
+struct winsize {
+	unsigned short ws_row;
+	unsigned short ws_col;
+	unsigned short ws_xpixel;
+	unsigned short ws_ypixel;
+};
+
 #define NCCS 32
 
 #include <bits/termios.h>
@@ -27,6 +34,9 @@ int cfsetispeed (struct termios *, speed_t);
 int tcgetattr (int, struct termios *);
 int tcsetattr (int, int, const struct termios *);
 
+int tcgetwinsize (int, struct winsize *);
+int tcsetwinsize (int, const struct winsize *);
+
 int tcsendbreak (int, int);
 int tcdrain (int);
 int tcflush (int, int);
diff --git a/src/termios/tcgetwinsize.c b/src/termios/tcgetwinsize.c
new file mode 100644
index 00000000..9b3a65a4
--- /dev/null
+++ b/src/termios/tcgetwinsize.c
@@ -0,0 +1,8 @@
+#include <termios.h>
+#include <sys/ioctl.h>
+#include "syscall.h"
+
+int tcgetwinsize(int fd, struct winsize *wsz)
+{
+	return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz);
+}
diff --git a/src/termios/tcsetwinsize.c b/src/termios/tcsetwinsize.c
new file mode 100644
index 00000000..e01d0e25
--- /dev/null
+++ b/src/termios/tcsetwinsize.c
@@ -0,0 +1,8 @@
+#include <termios.h>
+#include <sys/ioctl.h>
+#include "syscall.h"
+
+int tcsetwinsize(int fd, const struct winsize *wsz)
+{
+	return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz);
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-19 23:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 17:51 [musl] POSIX & SIGWINCH Rich Felker
2020-08-19 23:09 ` Rich Felker

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git