You can slip away from reading your parent process identifier very early in your process and then check, but of course, this is prone to race conditions. The parent who spawned may have died right away, and even before your process completed its first instruction.
If you have a way to check if a given PID belongs to an โexpectedโ parent, I think this is hard to do reliably.
unwind
source share