You can do it using strace.
strace -p $pid_of_process_you_want_to_see_stdout_of 2>&1| sed -re 's%^write\(1,[[:blank:]](.*),[[:blank:]]*[0-9]+\)[[:blank:]]*=[[:blank:]]*[0-9]+%\1%g'
You may want to improve the filter, but that would be another question. We have the output, but now need to tidy it.
Put this program(bellow) in file hello, and
chmod +x hello
echo -en "hello\nworld\n"
This one in hello1 and `chmod +x hello1
This one in hello2 and `chmod +x hello2
then run with
then find pid of process hello and type
pid_of_process_you_want_to_see_stdout_of=xyz where xyz it the pid of hello
then run line at top.
How it works.
When hello is run, bash forks, redirects fd1 to /dev/null, then execs hello.
Hello sends output to fd1 using system call write(1, ….
Kernel receives system call write(1, …, sees that fd 1 is connected to /dev/null and …
We then run strace (system-call trace) on hello, and see that it is calling write(1, "hello\nworld\n")
The rest if the line above is just selecting the appropriate line of the trace.