From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20929 invoked from network); 19 Aug 2020 23:10:17 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 19 Aug 2020 23:10:17 -0000 Received: (qmail 5183 invoked by uid 550); 19 Aug 2020 23:10:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5159 invoked from network); 19 Aug 2020 23:10:09 -0000 Date: Wed, 19 Aug 2020 19:09:57 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20200819230956.GA32728@brightrain.aerifal.cx> References: <20200724175111.GD6949@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: <20200724175111.GD6949@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] POSIX & SIGWINCH --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="winsize.diff" 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 @@ -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 +#include +#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 +#include +#include "syscall.h" + +int tcsetwinsize(int fd, const struct winsize *wsz) +{ + return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz); +} --yrj/dFKFPuw6o+aM--