cher@ihlpm.UUCP (cherepov) (05/17/85)
-- I have been trying to make a BSD 4.2 - configured program to work on System V. There are discrepancies between #include files in /usr/include and /usr/include/sys on two systems. One thing I do not have is BSD 4.2 #include file wait.h. Another is CBREAK #define'd somewhere in /usr/include/* or /usr/include/*/*. I guess I could do without wait.h, but the header file with CBREAK... Please. please. ..... Mike Cherepov
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (05/19/85)
> I have been trying to make a BSD 4.2 - configured program to > work on System V. > There are discrepancies between #include files in /usr/include > and /usr/include/sys on two systems. Understatement of the year. > One thing I do not have is BSD 4.2 #include file wait.h. That just defines the form of the status word returned by wait(2). The odds are good that you can just do the normal things with wait(2). > Another is CBREAK #define'd somewhere in /usr/include/* or /usr/include/*/*. This is from 7th Edition UNIX and is a bit in sg_flags that puts the keyboard handler into "half-cooked" mode. Simulate it by turning off ICANON in the termio struct.
guy@sun.uucp (Guy Harris) (05/26/85)
> There are discrepancies between #include files in /usr/include > and /usr/include/sys on two systems. > One thing I do not have is BSD 4.2 #include file wait.h. "wait.h" defines a structure with bit fields for pulling apart the "int" that "wait" fills in. 1) If the program doesn't use "wait3" (if it does, you're sunk; it's a 4.xBSD-only feature), just use masks to pull apart the value. w_termsig is the signal that caused the process to terminate (0 if it was terminated by "exit"ing). Lower 7 bits of the "int" (mask of 0177). w_coredump is the bit that indicates if the signal in question caused a core dump or not. 0200 bit of the "int". w_retcode is the exit status of the program. Next 8 bits of the "int" (mask of 0377, then shift right 8). w_stopval is 0177 if the process is stopped, not terminated. Same lower 7 bits as "w_termsig". w_stopsig is the signal that stopped the process. Same "next 8 bits" as "w_retcode". WSTOPPED is a manifest constant for the magic 0177 mentioned under "w_stopval". Just replace it with 0177. WIFSTOPPED(x) is a predicate that takes the "wait" return value and checks whether the process is stopped. Replace it with a test of ((int_value & 0177) == 0177) WIFSIGNALED(x) is a predicate that takes the "wait" return value and checks whether the process was terminated with a signal. Replace it with a test of ((int_value & 0177) != 0177 && (int_value & 0177) != 0) WIFEXITED(x) is a predicate that takes the "wait" return value and checks whether the process "exit"ed. Replace it with a test of ((int_value & 0177) == 0) People: please don't use the "wait.h" stuff unless you *really* have to or you absolutely *K*N*O*W* that the program will never ever EVER run under any non-4.xBSD-based UNIX. ("wait" is declared in the non-4.xBSD manual pages and in the non-4.xBSD lint libraries as taking a pointer to "int" as an argument, not a pointer to a "union wait". Furthermore, the bit fields inside that "int" are defined relative to the least-significant bit, so that two structure definitions are needed, one for big-endian machines and one for little-endian machines; code that uses shifts and masks will work regardless of the byte sex of the machine.) > Another is CBREAK #define'd somewhere in /usr/include/* or /usr/include/*/*. None of the above. CBREAK was part of the V7 terminal driver that the 4.xBSD driver is based on. Turning CBREAK on is equivalent to turning ICANON off. WARNING: programs written for the V7 driver or V7-based drivers like the 4.xBSD driver use TIOCGETP and TIOCSETP "ioctl"s (or the "gtty" and "stty" calls which are equivalent) with "struct sgttyb" structures. System {III,V} have these "ioctl"s (as well as "gtty" and "stty") BUT 1) they are not compatible with the V7 calls and 2) they are described as "conversion aide(s) (sic) only" in the comments in the S{3,5} terminal driver. As such, all calls to "gtty"/"ioctl(TIOCGETP)" or to "stty"/"ioctl(TIOCSETP)" should NOT be left intact if a V7/4.xBSD program is being moved to S{3,5}. Conversion of these calls, at least for programs that don't do anything fancy (most programs that fiddle the terminal modes of the standard input or output are just "full-screen" programs which don't do anything fancy) is straightforward but tedious. Grab a 4.xBSD manual (it describes the added features and corrects some errors in the V7 manual page) and an S{3,5} manual, and study the appropriate manual pages - TTY(4) in the Berkeley manual (Programmer's Manual for the multi-volume hand-held sets) and TERMIO(7) in the *ADMINISTRATOR'S* manual (yes, this is the wrong place for it - it belongs in the Programmer's manual; go yell at the AT&T documenation people) for S5 (User's Manual for S3). Guy Harris
alexis@reed.UUCP (Alexis Dimitriadis) (05/31/85)
> CBREAK was part of the V7 terminal driver that the > 4.xBSD driver is based on. Turning CBREAK on is equivalent to turning > ICANON off. WARNING: programs written for the V7 driver or V7-based drivers > like the 4.xBSD driver use TIOCGETP and TIOCSETP "ioctl"s (or the "gtty" and > "stty" calls which are equivalent) with "struct sgttyb" structures. System > {III,V} have these "ioctl"s (as well as "gtty" and "stty") BUT 1) they are not > compatible with the V7 calls and 2) they are described as "conversion > aide(s) (sic) only" in the comments in the S{3,5} terminal driver. Could some kind guru post a list of the corresponding calls for each enviroment? What IS the SysV equivalent to turning on the CBREAK bit? (call, types of arguments, and constant names!). A neat little list of the most common operations and their counterparts would be really handy. Thanks, Alexis Dimitriadis -- _______________________________________________ As soon as I get a full time job, the opinions expressed above will attach themselves to my employer, who will never be rid of them again. alexis @ reed ...teneron! \ ...seismo!ihnp4! - tektronix! - reed.UUCP ...decvax! /