Portably, you can use:
lsof -ad 1 -p "$pid"
To see what's open on fd 1 (stdout) of process of id $pid.
If that's open to a pipe or another inter-process communication channel, on Linux, you can add the -E option to see what process is at the other end.