下面显示的代码片段的工作方式是,在 fork 后,子进程 ssh 从 windows 到 Linux 机器,并在 linux 机器上运行 script1_bkt.csh。日志被转储到 Windows 路径($AngleLogFilePath\Angle_${date}.log === V:\ricky_angle_testing_63.1\depot\vfr\63.10\main\logs\angleLogsrickyPersonal\Angle_${date}.log)。
父进程(trialSet.pl 和 trialSetDepWint.pl)在前台运行,并且工作正常。
V:是 /dv/lmv/mentor/ 的网络文件管理器或 CISF
问题::
从 Windows 机器 ssh 到 Linux 机器并运行 script1_bkt.csh 的子进程(在 fork 进程之后)在某些时候(不是每次)都会卡住。
注意事项:在Linux机器(qwelnx45)上,一段时间后script1_bkt.csh的PID不存在,这意味着该过程已完成。但是,在 Windows 上,存在 ssh.exe 的 PID(使用哪个 script1_bkt.csh 在 Windows 上触发),这意味着在 Windows 上,命令 ($GoToUnix74 cd $ClientAltRoot/lkg ; source script1_bkt.csh ) 没有完成,并且得到了卡住。该脚本通常需要 3 小时才能完成,但有时它会因为卡住而永远无法完成。::: 这个脚本不会每次都卡住。
另外,还有一点很重要:当子进程卡在 windows 上时,虽然 script1_bkt.csh 在 Linux 上已经完成,但日志文件 ($AngleLogFilePath\Angle_${date}.log) 并没有包含 script1_bkt.csh 的所有数据给出即日志文件不完整(似乎是因为进程卡住了,它停止写入日志文件)
代码片段:
use File::Path qw( make_path );
my $ClientAltRoot = "/dv/lmv/mentor/ricky_angle_testing_63.1/depot/vfr/63.10/main/";
my $GoToUnix = "C:\\cygwin\\bin\\ssh.exe qwelnx45";
my $AngleLogFilePath = "V:\\ricky_angle_testing_63.1\\depot\\vfr\\63.10\\main\\logs\\angleLogsrickyPersonal";
my $date = strftime("%Y%m%d_%H%M%S", localtime(time));
make_path("$AngleLogFilePath") or warn "Failed to create dir $AngleLogFilePath";
my $aqpid;
# fork angle process
if ($aqpid = fork()) {
$SIG{CHLD} = 'DEFAULT';
} elsif (defined ($aqpid)) {
sleep 10;
print "Angle child started\n";
$angleReturnStatus = system ("$GoToUnix cd $ClientAltRoot/lkg ; source script1_bkt.csh > $AngleLogFilePath\\Angle_${date}.log ");
$angleFailed += 1 if ($angleReturnStatus > 0);
exit 0;
}
print "##### Starting the foreground script ###### \n";
system "$GoToUnix \"cd /home/ricky/; echo abc ; /home/ricky/trialSet.pl > setTrial_ricky/set_${date}.log\" ";
print "Ended SetDep\n";
print "Waiting as child process has not ended";
1 while (wait() != -1);
system ( "perl C:\\ricky\\Testing\\trialSetDepWint.pl ");
print "Demo script ended\n";
请告诉为什么进程卡住了?消除这个卡住问题的可能解决方案是什么?
-提前致谢。