Code review comment for lp:~marcustomlinson/unity-scopes-api/scope_process_lifetime

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> 720 + // 4. add the scope process to the death observer
> 721 +
> core::posix::ChildProcess::DeathObserver::instance().add(process_);
> 722 +}
>
> Shouldn't this happen early (before we start the process)? What if it dies
> shortly after we check that the state is Running in line #706, but before we
> register the observer?

There is never a time where you can add a ChildProcess to the death observer early enough. See, a ChildProcess can only be constructed after it's process is started, which is already too late as the process may have crashed immediately (hence the death observer misses that signal).

This was sorted out in process-cpp so that when an already dead process is added it will fire the on_process_death signal, which in turn, will then execute the correct ChildProcess tear down routine.

« Back to merge proposal