38 points · by yla92 · 2y ago · 23 comments
If you want to have visible debug information, you can either:
- call << std::flush;
- use << std::endl; which is basically equivalent to << "\n" << std::flush;
- use std::cerr instead of std::cout, which is unbuffered.
xterm -hold -e './a.out' - no segfault
xterm -hold -e '(./a.out)' - will print segfault
stdbuf -i0 -o0 -e0 /some/command
Where -i is for stdin, -o is for stdout, and -e is for stderr, and the number is the buffer size.