$p = open P, 'xxx|' 1) while (sysread P) {...}; close P; wait(); 2) while (1) {...if($p==waitpid($p,WNOHANG)){last}}; close P;