1 | This file describes cases where platforms we care about do not |
---|
2 | correctly implement the ANSI C and POSIX specifications. The cases |
---|
3 | described are: |
---|
4 | |
---|
5 | setsid() and Ultrix 4.2 |
---|
6 | getpgrp() and Ultrix, SunOS 4.x |
---|
7 | Pseudo-ttys and Ultrix 4.2 |
---|
8 | strerror() and SunOS |
---|
9 | |
---|
10 | setsid() and Ultrix 4.2 |
---|
11 | ----------------------- |
---|
12 | |
---|
13 | Under Ultrix 4.2, setsid() does not dissociate a process from its |
---|
14 | controlling tty. |
---|
15 | |
---|
16 | For a program using imake, an appropriate way to detect the problem |
---|
17 | is: |
---|
18 | |
---|
19 | #define HAVE_SETSID |
---|
20 | #ifdef ultrix |
---|
21 | /* Under Ultrix 4.2, setsid() doesn't dissociate the calling process |
---|
22 | * from its controlling tty. Use setpgid() and the TIOCNOTTY |
---|
23 | * ioctl instead. */ |
---|
24 | #undef HAVE_SETSID |
---|
25 | #endif |
---|
26 | |
---|
27 | For a program using Autoconf, you should put the following test in |
---|
28 | your aclocal.m4: |
---|
29 | |
---|
30 | AC_DEFUN(ATHENA_FUNC_SETSID, |
---|
31 | [AC_MSG_CHECKING(for working setsid) |
---|
32 | AC_CACHE_VAL(athena_cv_func_setsid, |
---|
33 | [AC_TRY_RUN([ |
---|
34 | #include <sys/types.h> |
---|
35 | #include <sys/stat.h> |
---|
36 | #include <fcntl.h> |
---|
37 | #include <unistd.h> |
---|
38 | int main() |
---|
39 | { |
---|
40 | setsid(); |
---|
41 | return (open("/dev/tty", O_RDWR, 0666) < 0) ? 0 : 1; |
---|
42 | } |
---|
43 | ], athena_cv_func_setsid=yes, athena_cv_func_setsid=no, |
---|
44 | athena_cv_func_setsid=no)])dnl |
---|
45 | AC_MSG_RESULT($athena_cv_func_regcomp) |
---|
46 | if test $athena_cv_func_regcomp = yes; then |
---|
47 | AC_DEFINE(HAVE_SETSID) |
---|
48 | fi]) |
---|
49 | |
---|
50 | and then put ATHENA_FUNC_SETSID in your configure.in. |
---|
51 | |
---|
52 | In either case, an appropriate workaround is: |
---|
53 | |
---|
54 | #ifndef HAVE_SETSID |
---|
55 | #include <sys/ioctl.h> |
---|
56 | static int bsd_emulate_setsid() |
---|
57 | { |
---|
58 | int fd, status; |
---|
59 | |
---|
60 | status = setpgid(getpid(), getpid()); |
---|
61 | if (status < 0) |
---|
62 | return status; |
---|
63 | fd = open("/dev/tty", O_RDWR, 0666); |
---|
64 | if (fd >= 0) { |
---|
65 | status = ioctl(fd, TIOCNOTTY, (char *) 0); |
---|
66 | close(fd); |
---|
67 | } |
---|
68 | return status; |
---|
69 | } |
---|
70 | #define setsid bsd_emulate_setsid |
---|
71 | #endif |
---|
72 | |
---|
73 | getpgrp() and Ultrix, SunOS 4.x |
---|
74 | ------------------------------- |
---|
75 | |
---|
76 | The BSD 4.3 getpgrp() interface takes a process ID argument indicating |
---|
77 | which process one wants the process group of. POSIX "simplified" the |
---|
78 | getpgrp() interface by eliminating the argument and assuming the |
---|
79 | calling process's ID. Ultrix and SunOS both have "POSIX" or "System |
---|
80 | V" environments which have the correct getpgrp() interface, but we |
---|
81 | don't use those environments. |
---|
82 | |
---|
83 | For a program using imake, an appropriate way to detect the problem |
---|
84 | is: |
---|
85 | |
---|
86 | #define GETPGRP_VOID |
---|
87 | #if defined(ultrix) || (defined(sun) && !defined(__svr4__)) |
---|
88 | /* Ultrix 4.2 and SunOS 4.1.3_U1 use the old BSD interface for |
---|
89 | * getpgrp(), which takes an argument. Use the BSD getpgrp() |
---|
90 | * interface instead of the POSIX interface. */ |
---|
91 | #undef GETPGRP_VOID |
---|
92 | #endif |
---|
93 | |
---|
94 | For a program which uses Autoconf, put AC_FUNC_GETPGRP in your |
---|
95 | configure.in file. |
---|
96 | |
---|
97 | In either case, an appropriate workaround is: |
---|
98 | |
---|
99 | #ifndef GETPGRP_VOID |
---|
100 | #include <sys/types.h> |
---|
101 | static pid_t bsd_emulate_getpgrp() |
---|
102 | { |
---|
103 | return getpgrp(getpid()); |
---|
104 | } |
---|
105 | #define getpgrp bsd_emulate_getpgrp |
---|
106 | #endif |
---|
107 | |
---|
108 | Pseudo-ttys and Ultrix 4.2 |
---|
109 | -------------------------- |
---|
110 | |
---|
111 | Opening a slave pty under Ultrix without opening the parent causes the |
---|
112 | pty to become unusable until a reboot. The best workaround is to |
---|
113 | always open the parent side of pseudo-ttys first. See the section on |
---|
114 | pseudo-ttys in the "nonstd" file in this directory for more |
---|
115 | information about obtaining a pseudo-tty. |
---|
116 | |
---|
117 | strerror() and SunOS |
---|
118 | -------------------- |
---|
119 | |
---|
120 | The standard way of getting the error message for an error value in |
---|
121 | ANSI C is the function strerror(). SunOS does not define strerror(). |
---|
122 | |
---|
123 | An incorrect solution is to declare sys_nerr and sys_errlist and use |
---|
124 | them directly. Not only is this solution nonstandard, but modern |
---|
125 | operating systems often have their own declarations of those |
---|
126 | variables, which may conflict with your declarations. |
---|
127 | |
---|
128 | For a program using imake, an appropriate way to detect the problem |
---|
129 | is: |
---|
130 | |
---|
131 | #define HAVE_STRERROR |
---|
132 | #if defined(sun) && !defined(__svr4__) |
---|
133 | /* SunOS 4.1.3_U1 doesn't have strerror(). Use sys_errlist |
---|
134 | * instead. */ |
---|
135 | #undef HAVE_STRERROR |
---|
136 | #endif |
---|
137 | |
---|
138 | For a program using autoconf, put AC_CHECK_FUNC(strerror) in your |
---|
139 | configure.in. |
---|
140 | |
---|
141 | In either case, an appropriate workaround is: |
---|
142 | |
---|
143 | #ifndef HAVE_STRERROR |
---|
144 | extern const char *const sys_errlist[]; |
---|
145 | #define strerror(x) (sys_errlist[x]) |
---|
146 | #endif |
---|