File: pty-fd

package info (click to toggle)
rxvt-unicode 7.9-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,312 kB
  • ctags: 4,499
  • sloc: ansic: 37,552; cpp: 17,600; sh: 2,916; perl: 2,035; makefile: 1,834
file content (22 lines) | stat: -rwxr-xr-x 413 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl

# sample script to illustrate the -pty-fd option

use IO::Pty;
use Fcntl;

my $pty = new IO::Pty;
fcntl $pty, F_SETFD, 0; # clear close-on-exec

system "rxvt -pty-fd " . (fileno $pty) . "&";
close $pty;

# now communicate with rxvt
my $slave = $pty->slave;

print $slave "hi! please enter something and press return (ctrl-d to exit):\n";

while (<$slave>) {
   print $slave "you entered: $_";
}