I am trying to test out my system and wish to emulate a condition, where the child process gets hung. For doing this, I am trying to attach the child process to GDB and putting a break on it. But things don’t seem to be going as expected.
Also, in the same vein, how do I know that a spawned child process is not progressing, but is hung?
Use can use SIGSTOP to hang a child process – but that is observably different from the child process going into an infinite loop, or a bad conditional wait – still it may be close enough for testing.
To check a child process has not hung, you have it send heart-beats to the parent (you’ll need some kind of communications channel for this – maybe stdin/stdout at a minimum). Then the child has hung if it fails to send a couple of heart-beats messages.