Quote:>>Also, I believe ioctl(TIOCGWINSZ...) is not POSIX; is there
>>a POSIX function for this?
No, there is no POSIX function for that.
Quote:>- Why is it that when I log in from an xterm to a Sun, then resize,
>TIOCGWINSZ on the remote sun gives the right answer, but when I log in
>to an rs6000, it does not?
Beats me. Worked fine when I rlogged in from my Sun to an RS/6000 here,
running AIX 3.2.
Quote:>- Which headers should be included?
>- Which is preferable, or standard?
There isn't a standard that covers all systems.
If we restrict ourselves to systems with "termio(s)" - which blows away
pre-4.3-reno BSD systems, for example - we find that:
1) 4.3-reno and Net-2 define TIOCGWINSZ and TIOCSWINSZ in
<sys/ioctl.h>, and do not automatically include <sys/ioctl.h>
if you include <sys/termios.h>, so you can't just include
<sys/termios.h> on those systems - you have to include
<sys/ioctl.h> (or something that forces it to be included).
2) SunOS 4.x defines them in <sys/ttycom.h>, which is included
by <sys/termios.h>, although you have to make sure
_POSIX_SOURCE is *not* defined (if it *is* defined, symbols
such as "TIOC[GS]WINSZ" that "pollute the namespace" aren't
defined). You can, therefore, get them with <sys/termios.h>.
You can also get them with <sys/ioctl.h>, as that includes
<sys/ttold.h>, which includes <sys/ttycom.h> - *however*,
<sys/ioctl.h>, for compatibility with pre-4.3-reno BSD
releases, defines stuff for the older V7-flavored tty
driver that collide with definitions in <sys/termios.h>
3) SunOS 5.x defines them in <sys/termios.h> as well - again,
only if _POSIX_SOURCE isn't defined. <sys/ioctl.h> appears
to act in the SunOS 4.x fashion only if BSD_COMP is defined.
I don't have a "more vanilla" SVR4 system handy; however, the
SVR4 documentation mentions TIOCGWINSZ and TIOCSWINSZ in the
"termios(7)" manual page, so I suspect it gives you
TIOC[GS]WINSZ if you include <sys/termios.h> and don't have
_POSIX_SOURCE defined. I suspect you may *not* get them if
you include <sys/ioctl.h> (it may do so if BSD_COMP is
4) AIX 3.2 defines them in <sys/ioctl.h>, although _ALL_SOURCE
has to be defined to have "struct winsize" defined.
<sys/ioctl.h> has a comment that it contains "ioctl
definitions a la 4.xBSD for BSD to AIX porting tools"; I've
no idea whether or not they're under the delusion that
TIOC[GS]WINSZ's only reason for existence is BSD compatibility.
<sys/termio.h> doesn't define them, and there doesn't appear
to be a <sys/termios.h> - at least not in "/usr/include/sys".
5) HP-UX 8.07 (or whatever the hell version the machine in
question is running) defines them in <sys/termio.h>, which is
included by <sys/termios.h>; I haven't bothered checking what
stuff has to be defined to turn that on, as their "vi" is
singularly obnoxious - even though "stty size" correctly
reports that my window has 66 rows, "vi" seems to insist that
it doesn't have 66 rows....
<sys/ioctl.h> includes only <sys/stdsyms.h>, which includes
nothing; <sys/ioctl.h> doesn't define TIOC[GS]WINSZ.
So systems seem to fall into two camps:
1) define it in <sys/termios.h> (at least if "strict POSIX
namespace" isn't turned on), and either don't define it in
<sys/ioctl.h> or don't encourage <sys/ioctl.h> to coexist
2) define it in <sys/ioctl.h> but not in <sys/termios.h>.
I somewhat prefer camp 1) (then again, I'm the one who put SunOS 4.x
*into* that camp); the fact that TIOC[GS]WINSZ pollute the POSIX
namespace doesn't bother me, as plenty of other tty driver features that
belong in <sys/termios.h> do so as well, so you're stuck with a "strict
POSIX" flag in any case.
If camp 1) causes some people a real problem, I'd vote for camp 3) -
have some separate include file, <sys/ttywinsz.h> or something such as
that - as long as *everybody* agrees on it, so you can write software
that uses "termios" and TIOC[GS]WINSZ without having to pollute it with
lots of stupid #ifdefs.