All pastes #979675 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-10 14:55 UTC
rendered paste body
do_vpn_connect() {
  sudo /usr/sbin/vpnc $1 --non-inter --dns-update no  &
  vpnc_pid=$!
  conn_stat=$?
  sleep $TIMEOUT | (
    read nothing  # wait on sleep to finish
    kill -0 $vpnc_pid >/dev/null 2>&1 || exit 
    kill $vpnc_pid >/dev/null 2>&1;
  ) &
  sleep_pid=$!

  wait $vpnc_pid
  wait_exit=$?;

  if ...some condition...; then
        conn_stat=-255;
  else
        conn_stat=$wait_exit;
  fi
  kill -0 $sleep_pid 2>/dev/null || return;  # sleep finished?
  kill $sleep_pid 2>/dev/null
}