you could use option `-p` : `sprintf('ps -p %d', $pid)`