I wrote a code to get a runtime error intentionally:
int main()
{
int a=5;
printf("Hello World\n");
printf("a=%s\n", a);
}
It gives:
$ ./error.o
Hello World
Segmentation Fault
$
Now, to record the runtime errors, I do:
$ ./error.o > so.txt
$ ./error.o &> soe.txt
But both the files are empty. Why?
EDIT:
I'm actually writing a script for remote compilation and execution of a c program. From the answers I get that Segmentation Fault
is not the program's error output. So, is there a way to capture that output? Also, the program is just a sample, so I can't add the statements. Can line-buffering be done any other way with redirections?