refactor pcntl checking