我有一个Perl脚本,它在运行时启动许多系统命令。
e.g,
#!/usr/bin/env perl
use strict;
use warnings;
# somethings...
qx(adb start-server);
# somethings...
my $telnet = $ENV{'WINDIR'}.'\sysnative\telnet.exe';
system("start $telnet $ip $port -f $telnet_log");
#something...
#here I want to kill the adb, telnet windows and any other process started by this script and then proceed to exit.
qx(adb kill-server);
qx(taskkill /F /IM telnet.exe);
exit;
如上所示,我确实在最后有kill命令,但由于某些原因,如果脚本在到达这些kill
命令之前死亡,那么adb和telnet进程仍然在运行,我希望它能够被清理掉总是,有办法吗?