#!/usr/local/roadm/bin/perl use strict; use warnings; use Net::SSH::Perl; print "Starting main program\n"; my @childs; my $user = "root"; my $handle; my $host = "zeus-b001"; $handle = Net::SSH::Perl->new($host); $handle->login($user, $user); my $cmd = "sleep 1"; my $pid = fork(); if ($pid) { # parent push(@childs, $pid); print "child pid is [$pid]\n"; } elsif ($pid == 0) { # child my $ret = sub1($handle, $cmd); print "ret is $ret\n"; exit 0; } else { die "couldnt fork: $!\n"; } foreach my $pid (@childs) { my $tmp = waitpid($pid, 0); print "done with pid $tmp\n"; } # The program hangs here my ($out,$err, $exit) = $handle->cmd("uname -a"); print "End of main program\n"; sub sub1 { my ($handle,$cmd) = @_; print "started child process\n"; my ($out,$err,$exit) = $handle->cmd($cmd); print "done with child process\n"; return 1; }