Issue
The code snippet shown below works in a way that after forking, the child process ssh from windows to Linux machine, and run script1_bkt.csh on linux machine. And logs are dumped to a windows path ($AngleLogFilePath\Angle_${date}.log === V:\ricky_angle_testing_63.1\depot\vfr\63.10\main\logs\angleLogsrickyPersonal\Angle_${date}.log).
Parent Processes(trialSet.pl and trialSetDepWint.pl) runs in the foreground, and works fine.
V: is network filer or CISF for /dv/lmv/mentor/
Issue::
Child process (after the fork process) which ssh onto Linux machine from windows machine and runs script1_bkt.csh get stuck at some point (not everytime).
Point to Note: On a Linux machine(qwelnx45), the PID of script1_bkt.csh doesn't exist after some time which means the process is completed. But, on windows, the PID of ssh.exe (using which script1_bkt.csh is triggered on windows) exists which means on windows, command ($GoToUnix74 cd $ClientAltRoot/lkg ; source script1_bkt.csh ) isn't completed, and got stuck. The script usually takes 3 hrs in completing, but sometimes it never completes as it gets stuck. ::: This script doesn't get stuck everytime.
Also, one more important point: When child process gets stuck on windows, although script1_bkt.csh is finished on Linux, the log file ( $AngleLogFilePath\Angle_${date}.log) doesn't have all the data which script1_bkt.csh gives i.e. Log file is incomplete (Seems because process got stuck, it stopped writing to log file)
CODE SNIPPET:
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";
Please tell why is the process getting stuck? What could be the possible solution to eliminate this stuck issue?
-Thanks in Advance.
Solution
Actually, the issue was due to the following reasons:
- Quick Mode was ON. ## I turned off the quick mode on my system as a solution.
- Interruption on the command prompt on which run/script is going on. ## Avoid using the machine while the run/script is going on. Because, when you work on the machine, willy-nilly you switch command prompts; and due to this switching, your run sometimes gets stuck until you press "ENTER" or any key.
I followed these two methods, and not seeing the issue now.
Thanks.
Answered By - AskQuestionsP