ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/ptytty.C
(Generate patch)

Comparing libptytty/src/ptytty.C (file contents):
Revision 1.54 by sf-exg, Mon Aug 25 13:33:46 2014 UTC vs.
Revision 1.55 by sf-exg, Thu Apr 9 13:50:36 2015 UTC

350 * Push STREAMS modules: 350 * Push STREAMS modules:
351 * ptem: pseudo-terminal hardware emulation module. 351 * ptem: pseudo-terminal hardware emulation module.
352 * ldterm: standard terminal line discipline. 352 * ldterm: standard terminal line discipline.
353 * ttcompat: V7, 4BSD and XENIX STREAMS compatibility module. 353 * ttcompat: V7, 4BSD and XENIX STREAMS compatibility module.
354 * 354 *
355 * After we push the STREAMS modules, the first open () on the slave side 355 * On Solaris, a process can acquire a controlling terminal in the
356 * should make the "ptem" (or "ldterm" depending upon either which OS 356 * following ways:
357 * version or which set of manual pages you have) module give us a 357 * - open() of /dev/ptmx or of a slave device without O_NOCTTY
358 * controlling terminal. We must already have close ()d the master side 358 * - I_PUSH ioctl() of the "ptem" or "ldterm" module on a slave device
359 * fd in this child process before we push STREAMS modules on because the 359 * The second case is problematic, because it cannot be disabled.
360 * documentation is really unclear about whether it is any close () on 360 * Fortunately, Solaris (10 and 11 at least) provides an undocumented
361 * the master side or the last close () - i.e. a proper STREAMS dismantling 361 * __IPUSH_NOCTTY ioctl which does not have this side-effect, so we
362 * close () - on the master side which causes a hang up to be sent 362 * use it if defined. See
363 * through - Geoff Wing 363 * https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/os/streamio.c#L3755
364 * https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/io/ptem.c#L203
365 * https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/io/ldterm.c#L794
366 * Note that an open() of a slave device autoloads the modules,
367 * with __I_PUSH_NOCTTY, if xpg[46] mode is enabled (which requires
368 * linking /usr/lib/values-xpg[46].o).
369 * https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/sys/open.c#L173
364 */ 370 */
371
372#ifdef __I_PUSH_NOCTTY
373# define PT_I_PUSH __I_PUSH_NOCTTY
374#else
375# define PT_I_PUSH I_PUSH
376#endif
377
365#if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H) 378#if defined(HAVE_ISASTREAM) && defined(HAVE_STROPTS_H)
366 if (isastream (tty) == 1) 379 if (isastream (tty) == 1)
367# endif 380# endif
368 { 381 {
369 ioctl (tty, I_PUSH, "ptem"); 382 ioctl (tty, PT_I_PUSH, "ptem");
370 ioctl (tty, I_PUSH, "ldterm"); 383 ioctl (tty, PT_I_PUSH, "ldterm");
371 ioctl (tty, I_PUSH, "ttcompat"); 384 ioctl (tty, PT_I_PUSH, "ttcompat");
372 } 385 }
373#endif 386#endif
374 387
375#if UTMP_SUPPORT 388#if UTMP_SUPPORT
376# if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) 389# if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines