]> xenbits.xensource.com Git - osstest.git/commitdiff
TestSupport: use timeout(1) flight-32167 flight-32235 flight-32307 flight-32332 flight-32333 flight-32334 flight-32335 flight-32336 flight-32337 flight-32338 flight-32339 flight-32340 flight-32341 flight-32342 flight-32343 flight-32344 flight-32345 flight-32347 flight-32348 flight-32349 flight-32350 flight-32351 flight-32352 flight-32353 flight-32354 flight-32355 flight-32356 flight-32357 flight-32358 flight-32359 flight-32360 flight-32361 flight-32362 flight-32363 flight-32364 flight-32365 flight-32366 flight-32368 flight-32369 flight-32370 flight-32371 flight-32372 flight-32373 flight-32374 flight-32375 flight-32376 flight-32377 flight-32378 flight-32379 flight-32380 flight-32381 flight-32383 flight-32384 flight-32385 flight-32386 flight-32387 flight-32389 flight-32390 flight-32391 flight-32392 flight-32393 flight-32394 flight-32395 flight-32396 flight-32397 flight-32398 flight-32399 flight-32400 flight-32401 flight-32402 flight-32403 flight-32404 flight-32405 flight-32406 flight-32407 flight-32408 flight-32409 flight-32410 flight-32411 flight-32412 flight-32413 flight-32414 flight-32415 flight-32417 flight-32418 flight-32419 flight-32420
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 8 Dec 2014 12:10:24 +0000 (12:10 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 8 Dec 2014 14:41:48 +0000 (14:41 +0000)
If a command we run times out, the machinery in cmd() will arrange
for the ts-* script to spot the timeout, and stop waiting for it.

However it is also necessary for the command we ran to die.  It has a
copy of the owner daemon fd, so if it doesn't, our resources won't get
freed.  In sufficiently exciting bugs, our allocation might continue
indefinitely, while a subprocess of ours hangs on after we are long
gone.

timeout(1) does not print a message when the process times out (!)  So
we can't do away with the logic in cmd().  We set the timeout(1)
timeout to 30s more than our own timeout, so that cmd() will time
out first and print a message.

We could use alarm(1) as we do in Osstest/Serial/sympathy.pm but that
program isn't packaged and its unsophisticated approach is not really
appropriate for arbitrary nonconsenting programs.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Osstest/TestSupport.pm

index a3b69367d690305d649e5986eb46acbd2d2ce39f..ca680c0226d5c25d322e533f704adc701a267698 100644 (file)
@@ -388,7 +388,10 @@ sub sshopts () {
 sub tcmdex {
     my ($timeout,$stdout,$cmd,$optsref,@args) = @_;
     logm("executing $cmd ... @args");
-    my $r= cmd($timeout,$stdout, $cmd,@$optsref,@args);
+    # We use timeout(1) as a backstop, in case $cmd doesn't die.  We
+    # need $cmd to die because we won't release the resources we own
+    # until all of our children are dead.
+    my $r= cmd($timeout,$stdout, 'timeout',$timeout+30, $cmd,@$optsref,@args);
     $r and die "status $r";
 }