Reputation: 1673
Suppose I spawn a process and connect its standard input to one end of a pipe I created. (I still write stuff to the other end.) Eventually it will call read() and if the pipe is empty it will then block while waiting for me to put more stuff in there. The OS kernel (mostly care about Linux here) knows exactly when this happens. But it doesn't tell me about it. I'm wondering if any of the following ideas might work to find out when this happens:
I suspect that at least one of the above tricks works if I want to use a normal pipe. But if the process I'm running is picky, then it might not want to get input from a pipe. Some programs insist on reading at least some inputs from the controlling terminal. This is fine: that's why we have pseudo-terminals. But I think that both of the above tricks break down if I want to know about when a process tries to read from its controlling terminal. There's one more trick I can think of that might work there, but I don't think it does:
There's also a desperate trick number four:
This idea is annoying because the child may spawn yet more children, so I'd have to trace them too. If any of them were setuid root then the whole thing stops working. And at this point I'm out of ideas.
Upvotes: 0
Views: 19