Thread timeout für system-Befehle (3 answers)
Opened by bieber at 2009-04-14 15:36

topeg
 2009-04-14 15:45
#120561 #120561
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
my $return=undef;
eval
{
  # alarm mit befehl belegen
  local $SIG{ALRM}=sub{die;}
  # timeout von 5 sekunden
  alarm(5);
  $return=qx/tuwas/;
  # timeout abschalten
  alarm(0);
}
if ($@)
{
 print "Befehl konnte nicht ausgeführt werden\n";
}
else
{
  print "Befehl erfolgreich abgesetzt\n";
}

View full thread timeout für system-Befehle