I have a function that is the handler of the SIGINT signal in my C program, that when is executed should simply execute the following commands:
void sigint_handler(int sig)
{
system("cat output.txt");
exit(0);
}
The problem is that the "cat" command doesn't seems to do anything. If I try to do something else instead of "cat", like "echo something" it works fine, so I believe the problem is with the "cat" and not with the system() function. The file "output.txt" is in the same directory of the C program, and if I try to execute cat on that file through another C script it works. Also if I try to execute that command from shell it works.
I've checked the return from the system("cat output.txt") and it's 0. So what can the problem be?
EDIT: The file output.txt is also open as a FILE stream (using fopen()) in the program, by another thread, could that be an issue maybe?