… | |
… | |
198 | { |
198 | { |
199 | int fd; |
199 | int fd; |
200 | |
200 | |
201 | setsid (); |
201 | setsid (); |
202 | |
202 | |
203 | #if defined(HAVE_DEV_PTMX) && defined(I_PUSH) |
|
|
204 | /* |
|
|
205 | * Push STREAMS modules: |
|
|
206 | * ptem: pseudo-terminal hardware emulation module. |
|
|
207 | * ldterm: standard terminal line discipline. |
|
|
208 | * ttcompat: V7, 4BSD and XENIX STREAMS compatibility module. |
|
|
209 | * |
|
|
210 | * After we push the STREAMS modules, the first open () on the slave side |
|
|
211 | * (i.e. the next section between the dashes giving us "tty opened OK") |
|
|
212 | * should make the "ptem" (or "ldterm" depending upon either which OS |
|
|
213 | * version or which set of manual pages you have) module give us a |
|
|
214 | * controlling terminal. We must already have close ()d the master side |
|
|
215 | * fd in this child process before we push STREAMS modules on because the |
|
|
216 | * documentation is really unclear about whether it is any close () on |
|
|
217 | * the master side or the last close () - i.e. a proper STREAMS dismantling |
|
|
218 | * close () - on the master side which causes a hang up to be sent |
|
|
219 | * through - Geoff Wing |
|
|
220 | */ |
|
|
221 | #if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H) |
|
|
222 | if (isastream (fd_tty) == 1) |
|
|
223 | # endif |
|
|
224 | { |
|
|
225 | ioctl (fd_tty, I_PUSH, "ptem"); |
|
|
226 | ioctl (fd_tty, I_PUSH, "ldterm"); |
|
|
227 | ioctl (fd_tty, I_PUSH, "ttcompat"); |
|
|
228 | } |
|
|
229 | #endif |
|
|
230 | |
|
|
231 | #ifdef TIOCSCTTY |
203 | #ifdef TIOCSCTTY |
232 | ioctl (fd_tty, TIOCSCTTY, NULL); |
204 | ioctl (fd_tty, TIOCSCTTY, NULL); |
233 | #else |
205 | #else |
234 | fd = open (ttyname (fd_tty), O_RDWR); |
206 | fd = open (ttyname (fd_tty), O_RDWR); |
235 | if (fd >= 0) |
207 | if (fd >= 0) |
… | |
… | |
373 | put (); |
345 | put (); |
374 | return false; |
346 | return false; |
375 | } |
347 | } |
376 | } |
348 | } |
377 | |
349 | |
|
|
350 | #if defined(HAVE_DEV_PTMX) && defined(I_PUSH) |
|
|
351 | /* |
|
|
352 | * Push STREAMS modules: |
|
|
353 | * ptem: pseudo-terminal hardware emulation module. |
|
|
354 | * ldterm: standard terminal line discipline. |
|
|
355 | * ttcompat: V7, 4BSD and XENIX STREAMS compatibility module. |
|
|
356 | * |
|
|
357 | * After we push the STREAMS modules, the first open () on the slave side |
|
|
358 | * should make the "ptem" (or "ldterm" depending upon either which OS |
|
|
359 | * version or which set of manual pages you have) module give us a |
|
|
360 | * controlling terminal. We must already have close ()d the master side |
|
|
361 | * fd in this child process before we push STREAMS modules on because the |
|
|
362 | * documentation is really unclear about whether it is any close () on |
|
|
363 | * the master side or the last close () - i.e. a proper STREAMS dismantling |
|
|
364 | * close () - on the master side which causes a hang up to be sent |
|
|
365 | * through - Geoff Wing |
|
|
366 | */ |
|
|
367 | #if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H) |
|
|
368 | if (isastream (tty) == 1) |
|
|
369 | # endif |
|
|
370 | { |
|
|
371 | ioctl (tty, I_PUSH, "ptem"); |
|
|
372 | ioctl (tty, I_PUSH, "ldterm"); |
|
|
373 | ioctl (tty, I_PUSH, "ttcompat"); |
|
|
374 | } |
|
|
375 | #endif |
|
|
376 | |
378 | return true; |
377 | return true; |
379 | } |
378 | } |
380 | |
379 | |