TABLE OF CONTENTS


::pwtk::remote_pidwait

SYNOPSIS

proc ::pwtk::remote_pidwait {user_at_host PID} {

PURPOSE

Wait for the process, running on the remote host with PID, to finish.

ARGUMENTS

SOURCE

    variable remote

    set host [rhost_ $user_at_host]
    
    # check if host is alive
    while { ! [host_is_up $user_at_host] } {
        incr attempts
        print "from [procName]: host '$host' is down (attempt #$attempts)"
        
        after $remote(time_interval_ms)
        
        if { $remote(max_attempts) > 0 && $attempts > $remote(max_attempts) } {
            ::pwtk::error "failed to connect to $host in $attempts attempts" 1
        }
    }

    # check if user can connect to host
    if { ! [can_connect $user_at_host] } {
        ::pwtk::error "cannot connect to '$user_at_host'" 1
    }

    # wait while remote PID is alive
    while { [remote_pidexists $user_at_host $PID] } {
        after $remote(time_interval_ms)
    }

    # old:
    #set cmd [list ::pwtk::rexec -i $user_at_host [list ps -p $PID -o pid=]]
    #while { [eval $cmd] eq $PID } {
    #    after $remote(time_interval_ms)
    #}
}