http://qs321.pair.com?node_id=11120246


in reply to Effect of redirecting output to /dev/null on $? value

As ikegami mentioned, the effect on $? is due to running a shell to perform the I/O redirection. If you can assume a Bourne shell, (probably a safe assumption on POSIX systems, which redirection to /dev/null already assumes) then you can use the exec shell command like so:

`exec my_executable_that_seg_faults > /dev/null`;

Note that this is the shell exec inside the qx//, not the Perl exec. The shell exec command causes the shell to replace itself with the desired executable and thus should cause $? to reflect the executable's exit status, instead of the shell's exit status.