… | |
… | |
222 | * Make our tty a controlling tty so that /dev/tty points to us |
222 | * Make our tty a controlling tty so that /dev/tty points to us |
223 | */ |
223 | */ |
224 | static int |
224 | static int |
225 | control_tty (int fd_tty) |
225 | control_tty (int fd_tty) |
226 | { |
226 | { |
227 | #ifndef __QNX__ |
|
|
228 | int fd; |
227 | int fd; |
229 | |
228 | |
230 | /* ---------------------------------------- */ |
229 | /* ---------------------------------------- */ |
231 | # ifdef HAVE_SETSID |
|
|
232 | setsid (); |
230 | setsid (); |
233 | # endif |
|
|
234 | # if defined(HAVE_SETPGID) |
|
|
235 | setpgid (0, 0); |
|
|
236 | # elif defined(HAVE_SETPGRP) |
|
|
237 | setpgrp (0, 0); |
|
|
238 | # endif |
|
|
239 | |
|
|
240 | /* ---------------------------------------- */ |
|
|
241 | # ifdef TIOCNOTTY |
|
|
242 | fd = open ("/dev/tty", O_RDWR | O_NOCTTY); |
|
|
243 | if (fd >= 0) |
|
|
244 | { |
|
|
245 | ioctl (fd, TIOCNOTTY, NULL); /* void tty associations */ |
|
|
246 | close (fd); |
|
|
247 | } |
|
|
248 | # endif |
|
|
249 | |
|
|
250 | /* ---------------------------------------- */ |
|
|
251 | fd = open ("/dev/tty", O_RDWR | O_NOCTTY); |
|
|
252 | if (fd >= 0) |
|
|
253 | close (fd); /* ouch: still have controlling tty */ |
|
|
254 | |
231 | |
255 | /* ---------------------------------------- */ |
232 | /* ---------------------------------------- */ |
256 | # if defined(PTYS_ARE_PTMX) && defined(I_PUSH) |
233 | # if defined(PTYS_ARE_PTMX) && defined(I_PUSH) |
257 | /* |
234 | /* |
258 | * Push STREAMS modules: |
235 | * Push STREAMS modules: |
… | |
… | |
286 | fd = open ("/dev/tty", O_WRONLY); |
263 | fd = open ("/dev/tty", O_WRONLY); |
287 | if (fd < 0) |
264 | if (fd < 0) |
288 | return -1; /* fatal */ |
265 | return -1; /* fatal */ |
289 | close (fd); |
266 | close (fd); |
290 | /* ---------------------------------------- */ |
267 | /* ---------------------------------------- */ |
291 | #endif /* ! __QNX__ */ |
|
|
292 | |
268 | |
293 | return 0; |
269 | return 0; |
294 | } |
270 | } |
295 | |
271 | |
296 | void |
272 | void |