I have a command that compiles test.cpp and is supposed to store output in the output file. Here is an example of my generated cmd:
g++ tmp/test.cpp -o tmp/test &> tmp/compile.out
when I use system(), it does not work. Even though it creates output file, it still prints everything to the main console window. When I execute it in terminal, it works just fine.
I also tried use popen() and fgets() (just copying the code from here) but same happened. I probably could just fork my process and use freopen or something but I have sockets and multiple threads running in the background. I guess they would be duplicated as well, which is not good.
Any ideas why it may fail?
systemmanpage on my local Linux install, it specifically uses/bin/shto execute the string. Redirect syntax differs between shells, and&>may be a bash extension. Whether/bin/shis a symlink to bash may depend on platform/distribution.