Reputation:
In linux we can access process parent like this:
current->parent
my question is how can we check if the parent still exists?
The reason is that I am implementing a loop that visits all ancestors of current process and want to know when to stop.
Upvotes: 1
Views: 408
Reputation: 225437
When the parent of a particular process exits, the child is inherited by the init process.
So you can check if the parent process is running if getppid()
returns a value other than 1.
Upvotes: 1