How to timeout waitpid without killing the child?
I am aware of the many questions regarding waitpid and timeouts but they all cover this by killing the child from within an alarm handler.

That is not what i want, i want to keep the process running but dispatch it from waitpid.

The underlaying problem I try to solve is a daemon process with a main loop that processes a queue. The tasks are processed one at a time.

If a task hangs the whole main loop hangs. To get around this `fork()` and `waitpid` seemed an obvious choice. Still if a task hangs the loop hangs.

I can think of workarounds where i do not use waitpid at all but i would have to track running processes another way as i still want to process one task at a time in parallel to possibly hanging tasks.

I could even kill the task but i would like to have it running to examine what exactly is going wrong. A kill handler that dumps some debug information is also possible.

Anyway, the most convenient way to solve that issue is to timeout waitpid if possble.
How to timeout waitpid without killing the child?
===

I am aware of the many questions regarding waitpid and timeouts but they all cover this by killing the child from within an alarm handler.

That is not what i want, i want to keep the process running but dispatch it from waitpid.

The underlaying problem I try to solve is a daemon process with a main loop that processes a queue. The tasks are processed one at a time.

If a task hangs the whole main loop hangs. To get around this `fork()` and `waitpid` seemed an obvious choice. Still if a task hangs the loop hangs.

I can think of workarounds where i do not use waitpid at all but i would have to track running processes another way as i still want to process one task at a time in parallel to possibly hanging tasks.

I could even kill the task but i would like to have it running to examine what exactly is going wrong. A kill handler that dumps some debug information is also possible.

Anyway, the most convenient way to solve that issue is to timeout waitpid if possble.