libcamera: process: Use pid_ member to decide if running
Instead of using a separate member variable, use `pid_ > 0` to determine if the process is still running. Previously the value of `pid_` was not reset to -1 when the process terminated, but since it is only meaningful while the process is running, reset it to -1 in `Process::died()`. Neither `pid_` nor `running_` are exposed, so this change has no effect on the public interface or observable behaviour. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -208,7 +208,7 @@ const struct sigaction &ProcessManager::oldsa() const
|
||||
*/
|
||||
|
||||
Process::Process()
|
||||
: pid_(-1), running_(false), exitStatus_(NotExited), exitCode_(0)
|
||||
: pid_(-1), exitStatus_(NotExited), exitCode_(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ int Process::start(const std::string &path,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (running_)
|
||||
if (pid_ > 0)
|
||||
return -EBUSY;
|
||||
|
||||
for (int fd : fds) {
|
||||
@@ -257,8 +257,6 @@ int Process::start(const std::string &path,
|
||||
pid_ = childPid;
|
||||
ProcessManager::instance()->registerProcess(this);
|
||||
|
||||
running_ = true;
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
if (isolate())
|
||||
@@ -348,7 +346,7 @@ int Process::isolate()
|
||||
*/
|
||||
void Process::died(int wstatus)
|
||||
{
|
||||
running_ = false;
|
||||
pid_ = -1;
|
||||
exitStatus_ = WIFEXITED(wstatus) ? NormalExit : SignalExit;
|
||||
exitCode_ = exitStatus_ == NormalExit ? WEXITSTATUS(wstatus) : -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user