I can't use the Linux command tee at the time the C program gets executed since I can't find which line of the code in a big project precisely that runs this program. I am struggling to come up with a way to call the tee command inside the C program to redirect its printf statement to a log file also. The problem is that I can't call tee without an executable like "./exe | tee some.log" since the program is already executed. I did some research on how to get the stdout of a running process and saw some answers suggesting to check out /proc//fd/1. But I don't know why "1"(stdout) file is empty, and I was expecting the file should store the printf output of the process.
Sincerely appreciate for any help!