if( kill 0, $pid ) { # the process is still running } else { # has gone away. }