is child blocked on read?

I have forked a child process that redirects stdin to one pipe and stdout to another. The child then calls execv.

The parent reads from the pipe the child's stdout is driected to and writes to the pipe that has child's stdin.

Is there a way to know if the child is blocked on reading from the pipe waiting for parent to write to it?
Yes. Here's how in Linux:

You'll need to use strace to trace the child process and see what system calls it is executing.

/usr/bin/strace -p <pid-of-child>

Since stdin is file descriptor 0, you should see the child blocked on some kind of read of file descriptor 0.
I'm trying to call strace inside a test program using
 
execl("/usr/bin/strace",  "-p", <pid converted to string>.c_str(), NULL)

but evertime i try it it says
-p: <pid of the process>: command not found
Last edited on
figured it out:
 
execl("/usr/bin/strace", "strace", "-p", <pid converted to string>.c_str(), NULL)
Topic archived. No new replies allowed.