fix bugs in process lifetime management