I have a C program that outputs some information to the console and then goes to infinite loop. I need to run the program on the background and redirect the output to a log file. The redirection works if the program does not have the infinite loop, what nothing is written if the program have the infinite loop.
for example, this program test.c:
#include <stdio.h>
main (void) {
printf("Hello world\n");
while(1);
}
if i run it i see on the console the line Hello world but if i run ./test > logfile i don't get anything written on the file.
Is there any way to do this to work?
Thanks!