How can I implement ‘tee’ programmatically in C?
You could popen() the tee program. Or you can fork() and pipe stdout through a child process such as this (adapted from a real live program I wrote, so it works!): void tee(const char* fname) { int pipe_fd[2]; check(pipe(pipe_fd)); const pid_t pid = fork(); check(pid); if(!pid) { // our log child close(pipe_fd[1]); // Close unused … Read more