1Pty(3) User Contributed Perl Documentation Pty(3)
2
3
4
6 IO::Pty - Pseudo TTY object class
7
9 1.07
10
12 use IO::Pty;
13
14 $pty = new IO::Pty;
15
16 $slave = $pty->slave;
17
18 foreach $val (1..10) {
19 print $pty "$val\n";
20 $_ = <$slave>;
21 print "$_";
22 }
23
24 close($slave);
25
27 "IO::Pty" provides an interface to allow the creation of a pseudo tty.
28
29 "IO::Pty" inherits from "IO::Handle" and so provide all the methods
30 defined by the "IO::Handle" package.
31
32 Please note that pty creation is very system-dependend. If you have
33 problems, see IO::Tty for help.
34
36 new
37 The "new" constructor takes no arguments and returns a new file
38 object which is the master side of the pseudo tty.
39
41 ttyname()
42 Returns the name of the slave pseudo tty. On UNIX machines this
43 will be the pathname of the device. Use this name for informa‐
44 tional purpose only, to get a slave filehandle, use slave().
45
46 slave()
47 The "slave" method will return the slave filehandle of the given
48 master pty, opening it anew if necessary. If IO::Stty is
49 installed, you can then call "$slave->stty()" to modify the termi‐
50 nal settings.
51
52 close_slave()
53 The slave filehandle will be closed and destroyed. This is neces‐
54 sary in the parent after forking to get rid of the open filehandle,
55 otherwise the parent will not notice if the child exits. Subse‐
56 quent calls of "slave()" will return a newly opened slave filehan‐
57 dle.
58
59 make_slave_controlling_terminal()
60 This will set the slave filehandle as the controlling terminal of
61 the current process, which will become a session leader, so this
62 should only be called by a child process after a fork(), e.g. in
63 the callback to "sync_exec()" (see Proc::SyncExec). See the "try"
64 script (also "test.pl") for an example how to correctly spawn a
65 subprocess.
66
67 set_raw()
68 Will set the pty to raw. Note that this is a one-way operation,
69 you need IO::Stty to set the terminal settings to anything else.
70
71 On some systems, the master pty is not a tty. This method checks
72 for that and returns success anyway on such systems. Note that
73 this method must be called on the slave, and probably should be
74 called on the master, just to be sure, i.e.
75
76 $pty->slave->set_raw();
77 $pty->set_raw();
78
79 clone_winsize_from(\*FH)
80 Gets the terminal size from filehandle FH (which must be a termi‐
81 nal) and transfers it to the pty. Returns true on success and
82 undef on failure. Note that this must be called upon the slave,
83 i.e.
84
85 $pty->slave->clone_winsize_from(\*STDIN);
86
87 On some systems, the master pty also isatty. I actually have no
88 idea if setting terminal sizes there is passed through to the
89 slave, so if this method is called for a master that is not a tty,
90 it silently returns OK.
91
92 See the "try" script for example code how to propagate SIGWINCH.
93
95 IO::Tty, IO::Tty::Constant, IO::Handle, Expect, Proc::SyncExec
96
98 As this module is mainly used by Expect, support for it is available
99 via the two Expect mailing lists, expectperl-announce and expect‐
100 perl-discuss, at
101
102 http://lists.sourceforge.net/lists/listinfo/expectperl-announce
103
104 and
105
106 http://lists.sourceforge.net/lists/listinfo/expectperl-discuss
107
109 Originally by Graham Barr <gbarr@pobox.com>, based on the Ptty module
110 by Nick Ing-Simmons <nik@tiuk.ti.com>.
111
112 Now maintained and heavily rewritten by Roland Giersig <RGier‐
113 sig@cpan.org>.
114
115 Contains copyrighted stuff from openssh v3.0p1, authored by Tatu Ylonen
116 <ylo@cs.hut.fi>, Markus Friedl and Todd C. Miller <Todd.Miller@courte‐
117 san.com>.
118
120 Now all code is free software; you can redistribute it and/or modify it
121 under the same terms as Perl itself.
122
123 Nevertheless the above AUTHORS retain their copyrights to the various
124 parts and want to receive credit if their source code is used. See the
125 source for details.
126
128 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WAR‐
129 RANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER‐
130 CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
131 NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDEN‐
132 TAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
133 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
134 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
135 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
136 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
137 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
138
139 In other words: Use at your own risk. Provided as is. Your mileage
140 may vary. Read the source, Luke!
141
142 And finally, just to be sure:
143
144 Any Use of This Product, in Any Manner Whatsoever, Will Increase the
145 Amount of Disorder in the Universe. Although No Liability Is Implied
146 Herein, the Consumer Is Warned That This Process Will Ultimately Lead
147 to the Heat Death of the Universe.
148
149
150
151perl v5.8.8 2006-09-10 Pty(3)