I run the command
./a.out < in &> output.txtI want the errors also to be placed in
output.txt
.The
exit
status of the command was 139 and on terminal its output was:
Segmentation fault (core dumped)
and the file output.txt
was empty.
I run the command
./a.out < in &> output.txtI want the errors also to be placed in
output.txt
.exit
status of the command was 139 and on terminal its output was:
Segmentation fault (core dumped)
and the file output.txt
was empty.
If you want both the error messages from
a.out
and the stringto be appended to
output.txt
, then you have to redirect the shell'sstderr
as well. E.g.,This is because the segfault message is coming from the shell itself.
The message
Segmentation fault (core dumped)
is not coming from your program.It's produced by shell as result of a signal received by it. It's not a part of stderr or stdout of your program.
So shell's message can be captured as: