timeout if subprocesses don't start; note Changes
David Golden
15 years ago
8 | 8 |
|
9 | 9 |
0.04
|
10 | 10 |
|
11 | |
|
|
11 |
Added:
|
|
12 |
|
|
13 |
- Can capture/tee even if STDIN, STDOUT or STDERR are closed prior to
|
|
14 |
capture/tee block
|
|
15 |
|
|
16 |
- Generally, added more error handling
|
|
17 |
|
|
18 |
Fixed:
|
|
19 |
|
|
20 |
- Will timeout instead of hang if subprocesses fail to start
|
|
21 |
|
12 | 22 |
0.03 Fri Feb 20 13:03:08 EST 2009
|
13 | 23 |
|
14 | 24 |
Added:
|
139 | 139 |
$stash->{pid}{$which} = $pid
|
140 | 140 |
}
|
141 | 141 |
|
|
142 |
sub _files_exist { -f $_ || return 0 for @_; return 1 }
|
|
143 |
|
142 | 144 |
sub _wait_for_tees {
|
143 | 145 |
my ($stash) = @_;
|
144 | |
for my $file ( values %{$stash->{flag_files}} ) {
|
145 | |
1 until -f $file; # XXX should add alarm and timeout
|
146 | |
unlink $file
|
147 | |
};
|
|
146 |
my $start = time;
|
|
147 |
my @files = values %{$stash->{flag_files}};
|
|
148 |
1 until _files_exist(@files) || (time - $start > 30);
|
|
149 |
die "Timed out waiting for subprocesses to start" if ! _files_exist(@files);
|
|
150 |
unlink $_ for @files;
|
148 | 151 |
}
|
149 | 152 |
|
150 | 153 |
sub _kill_tees {
|