#! /usr/bin/perl -w
use IO::Pipe;
my $srcdir=$ENV{'srcdir'};
$srcdir="." if !defined $srcdir;
my $NEW_SHELL=$0=~/\//?$0:"./$0";
if($ENV{'SHELL'} eq $NEW_SHELL) {
  open(STDOUT, "> test-dosout") || failed("open(test-dosout)");
  open(STDERR, "> test-stderr") || failed("open(test-stderr)");
  exec "fakeroot", "./dos", "-F", "$srcdir/dosemu.conf" || failed("exec");
  exit 255;
}
$ENV{'SHELL'} = $NEW_SHELL;
my $pipe = new IO::Pipe;
defined(my $pid = fork()) || failed("fork()");
if($pid == 0) {
  # Child
  $pipe->reader();
  open(STDIN, "<&".fileno($pipe)) || failed("dup()");
  open(STDOUT, ">/dev/null") || failed("open(/dev/null)");
  exec(qw(script test-log)) || failed("exec(script, test-log)");
  exit 255;
};
$SIG{'PIPE'}='IGNORE';
# Parent.
$pipe->writer();
$pipe->autoflush(1);
while(<>) {
  print $pipe $_;
};
waitpid($pid, 0) || failed("waitpid");
exit ($?>255?$?>>8:$?);

sub failed {
  die("$0: $_[0] failed: $!\n");
}

#  
#  Local Variables:
#  mode:perl
#  perl-indent-level:2
#  End:
