Re: [dev] [sbase] [PATCH] ls fallback if ioctl does not work

From: FRIGN <dev_AT_frign.de>
Date: Sun, 15 Feb 2015 18:34:48 +0100

On Sun, 15 Feb 2015 17:50:19 +0100
k0ga_AT_shike2.com wrote:

> You can trust the value of COLUMNS. I think this is the correct way
> programs must detect the size of the terminal.

The stress is _portably_.

Quoting ioctl(2) manpage:
CONFORMING TO
       No single standard. Arguments, returns, and semantics of ioctl()
      vary according to the device driver in question (the call is used as
      a catch-all for operations that don't cleanly fit the UNIX stream
      I/O model). See ioctl_list(2) for a list of many of the known ioctl()
      calls. The ioctl() function call appeared in Version 7 AT&T UNIX.

The ioctl() can be assumed to be present on all systems, but in case
TIOCGWINSZ doesn't exist, we fall back to the fixed value. This is the
best of both worlds.

Cheers

FRIGN

-- 
FRIGN <dev_AT_frign.de>
Received on Sun Feb 15 2015 - 18:34:48 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 15 2015 - 18:36:17 CET