Implement process lifecycle events, fixes #1534

See #1534