# get the remote end ready to receive $nt->print "rz\r"; use IO::Pty (); $pty = new IO::Pty or die $!; ## Execute sz in another process. unless ($pid = fork) { # child process die "problem spawning program: $!\n" unless defined $pid; ## Disassociate process from existing controlling terminal. use POSIX (); POSIX::setsid or die "setsid failed: $!"; ## Associate process with a new controlling terminal. my $tty = $pty->slave; my $tty_fd = $tty->fileno; close $pty; ## Make stdio use the new controlling terminal. open STDIN, "<&$tty_fd" or die $!; open STDOUT, ">&$tty_fd" or die $!; open STDERR, ">&STDOUT" or die $!; close $tty; exec "sz @filenames" or die "problem executing sz\n";" }