7 # Run @$argv in the background with stdout redirected to $out.
11 if (not defined $pid) {
14 open STDOUT, ">&", $out;
16 exec(@$argv) or die "cannot exec '$argv->[0]': $!"
21 # Wait for $pid to finish.
23 # Simplified from wait_or_whine() in run-command.c.
26 my $waiting = waitpid($pid, 0);
28 die "waitpid failed: $!";
31 warn "died of signal $code";
41 # Note: the real sendfile() cannot read from a terminal.
43 # It is unspecified by POSIX whether reads
44 # from a disconnected terminal will return
45 # EIO (as in AIX 4.x, IRIX, and Linux) or
46 # end-of-file. Either is fine.
47 copy($in, $out, 4096) or $!{EIO} or die "cannot copy from child: $!";
51 die "usage: test-terminal program args";
53 my $master = new IO::Pty;
54 my $slave = $master->slave;
55 my $pid = start_child(\@ARGV, $slave);
57 xsendfile(\*STDOUT, $master);
58 exit(finish_child($pid));