… | |
… | |
225 | control_tty (int fd_tty) |
225 | control_tty (int fd_tty) |
226 | { |
226 | { |
227 | int fd; |
227 | int fd; |
228 | |
228 | |
229 | /* ---------------------------------------- */ |
229 | /* ---------------------------------------- */ |
230 | # ifdef HAVE_SETSID |
|
|
231 | setsid (); |
230 | setsid (); |
232 | # endif |
|
|
233 | # if defined(HAVE_SETPGID) |
|
|
234 | setpgid (0, 0); |
|
|
235 | # elif defined(HAVE_SETPGRP) |
|
|
236 | setpgrp (0, 0); |
|
|
237 | # endif |
|
|
238 | |
|
|
239 | /* ---------------------------------------- */ |
|
|
240 | # ifdef TIOCNOTTY |
|
|
241 | fd = open ("/dev/tty", O_RDWR | O_NOCTTY); |
|
|
242 | if (fd >= 0) |
|
|
243 | { |
|
|
244 | ioctl (fd, TIOCNOTTY, NULL); /* void tty associations */ |
|
|
245 | close (fd); |
|
|
246 | } |
|
|
247 | # endif |
|
|
248 | |
|
|
249 | /* ---------------------------------------- */ |
|
|
250 | fd = open ("/dev/tty", O_RDWR | O_NOCTTY); |
|
|
251 | if (fd >= 0) |
|
|
252 | close (fd); /* ouch: still have controlling tty */ |
|
|
253 | |
231 | |
254 | /* ---------------------------------------- */ |
232 | /* ---------------------------------------- */ |
255 | # if defined(PTYS_ARE_PTMX) && defined(I_PUSH) |
233 | # if defined(PTYS_ARE_PTMX) && defined(I_PUSH) |
256 | /* |
234 | /* |
257 | * Push STREAMS modules: |
235 | * Push STREAMS modules: |