Reputation: 101
When my program reaches the end, it prints out "Sleep for X seconds" then executes sleep(X). However, after the print happens, the program does not hang at all and exits. Using ps I can see that the process is still running in the background (though this may just be a child zombie).
Very basic hierarchy of my code:
main -> func1 -> fork multiple func2, set alarm() -(alarm goes off)> func3
Using printf and fflush, func2 never gets entered but it's called in func1 after a successful child process is spawned.
I've tried using gdb but it appears to mess up when I start using shared memory between parent/child with fork().
There's over 1000 lines of code, so posting it all would be rather much.
Question: Anyone with an idea on how to debug or have an idea of what may cause this? Note: All calls to exit() are coupled with a perror() before.
Upvotes: 0
Views: 115
Reputation: 101
The issue was an incorrect access to shared memory. Abruptly stopped the program without any errors.
Upvotes: 1