Consider the following very basic program, which has appeared in many forms on other questions here.
#include <string.h>
int main() {
char message[8];
strcpy(message, "Hello, world!");
}
On my system, if I put this in a file called Classic.c
, compile it with no special flags and run it, I get the following output.
$ gcc -o Classic Class.c
$ ./Classic
*** stack smashing detected ***: ./Classic terminated
Aborted (core dumped)
Normally, program output goes to stderr
or stdout
, so I expected that the following would produce no output.
./Classic 2> /dev/null > /dev/null
However, the output is exactly the same, so I have three questions to this scenario.
- What stream is being printed to here?
- How could I write code that prints to this special stream (without smashing my stack deliberately).
- How can I redirect the output of this stream?
Note I am running on a Linux system. Specifically, Ubuntu 14.04.