winsize struct

Steve Summit scs at adam.mit.edu
Wed Feb 13 14:22:38 AEST 1991


In article <1991Feb12.211450.28938 at athena.mit.edu> jik at athena.mit.edu (Jonathan I. Kamens) writes:
>...if you're using a system that doesn't define the winsize structure
>in any of its header files, the most likely explanation is that the system
>doesn't *support* the SIGWINCH signal or the TIOCGWINSZ/TIOCSWINSZ ioctl's...
>The programs should be written in such a way... to disable the... winsize
>stuff... using preprocessor symbols to determine whether the system on which
>they are being compiled has winsize.

Furthermore, this is one happy case in which you *don't* have to
invent your own preprocessor symbols.  (Jon probably understands
this, but I want to make the notion explicit.)  The code in
question can be made conditional on

	#ifdef SIGWINCH

and/or

	#ifdef TIOCSWINSZ

No Makefile editing, no config scripts, no multiplicity-of-
features-lumped-under-one-OS-specific-macro.  (Of course,
figuring out what to #include may be tricky, but here it really
ought to be <signal.h> and <sgtty.h>, respectively.)

With a bit of creativity, you can use tricks like these for a
number of other OS-dependent features.  For example, make your
symbolic link support conditional on S_IFLNK, after #including
<sys/stat.h>.  (If you try to make symbolic link code conditional
on something like BSD4, you make life difficult for people trying
to compile the code on a non-BSD system which does have symbolic
links but which otherwise isn't much like BSD.)  Don't put the
code for catching SIGTSTP inside #ifdef JOBCONTROL; put it inside
#ifdef SIGTSTP.  Settable line disciplines?  TIOCSETD.
Etc.

                                            Steve Summit
                                            scs at adam.mit.edu



More information about the Comp.unix.programmer mailing list