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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Effect of redirecting output to /dev/null on $? value
by ikegami (Patriarch) on Aug 03, 2020 at 00:39 UTC | |
by Anonymous Monk on Aug 03, 2020 at 06:57 UTC | |
Re^2: Effect of redirecting output to /dev/null on $? value
by afoken (Chancellor) on Aug 04, 2020 at 20:27 UTC | |
by jcb (Parson) on Aug 05, 2020 at 00:01 UTC | |
by ikegami (Patriarch) on Aug 05, 2020 at 04:11 UTC | |
by ikegami (Patriarch) on Aug 05, 2020 at 04:03 UTC |
In Section
Seekers of Perl Wisdom