summaryrefslogtreecommitdiffstats
path: root/t/100-system.t
blob: bfc423a665805c05f502bd8aa32dc9f918f89439 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;
use IO::Pty::Easy;

my $pty = IO::Pty::Easy->new;
$pty->spawn("$^X -ple ''");
my $output;
TODO: {
    local $TODO = "sigchld breaks things...";
    eval {
        local $SIG{ALRM} = sub { die "alarm\n" };
        alarm 5;
        $output = `$^X -e 'print "foo"'`;
        alarm 0;
    };
    isnt($@, "alarm\n", "system() didn't time out");
    is($output, "foo", "system() got the right value");
}
$pty->kill;
undef $output;
eval {
    local $SIG{ALRM} = sub { die "alarm2\n" };
    alarm 5;
    $output = `$^X -e 'print "bar"'`;
    alarm 0;
};
isnt($@, "alarm2\n", "system() didn't time out (after kill)");
is($output, "bar", "system() got the right value (after kill)");
$pty->close;