redbrick has asked for the wisdom of the Perl Monks concerning the following question:
Unfortunately, sometimes the spawned process simply does not finish. In order to prevent processes hanging out there, I wish to set a timeout, but I would need to set an asynchronous process (spam the ssh session, wait for its output in a loop, while incrementing a counter; when the counter exceeds the limit, just kill it). So, the question: there is a way to implement this kind of asynchronous communication?my $pid = open(PSLIST, " ssh -2 $user\@ $peer ./pslist | ") || die "Remote process list gathering error:\n$!.\n"; while(<PSLIST>){ chomp($_); push(@pslist, $_); } close(PSLIST); foreach (@service){ # .. check the existence of a process }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read a process output asynchronously
by zengargoyle (Deacon) on Oct 14, 2003 at 21:50 UTC | |
|
Re: Read a process output asynchronously
by etcshadow (Priest) on Oct 15, 2003 at 01:20 UTC | |
|
Re: Read a process output asynchronously
by delirium (Chaplain) on Oct 15, 2003 at 00:54 UTC | |
|
Re: Read a process output asynchronously
by tedrek (Pilgrim) on Oct 15, 2003 at 03:49 UTC |