The script command starts a new login process to capture terminal input and output, so the rest of your program won't run until it's completed.
You can do this in one of two ways: you could use script, but have it shell back to your program:
Code:
script -c '/path/to/program args'
Alternatively, if all you want to do is to capture the output of the program, you can reopen standard output (and/or standard error) like this:
Code:
freopen("log.out", "w+", stdout);
You might also look to using /dev/tty to get the actual terminal I/O if you're already doing stream redirection on stdout.
Hope that helps,
—Robert J Lee