It must be really simple but I can't catch it.
This is a trivial C program writing to stdout:
root@oceanLondon:~/tst# cat tst.c
#include <stdio.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
for (; ;) {
printf("Hello world!\n");
sleep(1);
}
return 0;
}
Now, if I want to write the output to my screen and a file:
root@oceanLondon:~/tst# ./tst |tee file
it just do not work, I have empty screen and empty file.
if I do a program that exits, then it perfectly works, e.g.
root@oceanLondon:~/tst# ls |tee file
Makefile
file
qq
tst
tst.c
tst.o
root@oceanLondon:~/tst# cat file
Makefile
file
qq
tst
tst.c
tst.o
root@oceanLondon:~/tst#
Is it some kind of buffering issue? And can someone help me to do tee on a continues program, please?