I believe signals are a cleaner way to communicate with a process/task than using shared memory (global variables) as they're easier to reason about. Additionally you don't have any of the synchronisation issues you've got with shared variables, specifically keeping the set of three (PID, is-task-alive bool, should-task-stop bool) in sync.