I'm writing a program prog
that is run from the terminal and (for now) performs the same function as an existing program eprog
.
I would like to be able to my program against the existing one by writing a third program in C that:
- Takes input from (
stdin
) - Sends that input to both
prog
andeprog
- Compares the terminal output from each, printing an error if they differ or else exiting normally.
What would be the best way to implement this? I'm aware of the existence of fork()
, but have never used it and am not sure if it is the more appropriate solution here.