in reply to Detect a hung process

If you can't modify to the program you want to monitor, you may have to resort to looking to see how long the process has been in a continuous blocked state, possibly by looking at the output from some form of the 'ps' command on your system.

Otherwise, if you want to interrupt the calls, look at timing them out with alarm(). This doesn't always work (esp for IO blocked calls).

One low tech solution might be to have your program touch a file just before it begins a blockable call. Another process could watch for this file and complain loudly if it existed and its timestamp was old. Once your first process finished the call, it could just remove the touched file. You can use lockfiles, logfiles, semaphores, shared memory, signals, parent/child pipes, etc in the same kind of way if you are creative, but of course you have to implement this every place in your code where you make this kind of call.