diff --git a/src/Process.cpp b/src/Process.cpp index 265fe46..157d8f8 100644 --- a/src/Process.cpp +++ b/src/Process.cpp @@ -49,7 +49,7 @@ namespace nanosm { for(usize i = 0; i < exp.words.size(); ++i) argv[i] = exp.words[i].data(); - execvp(exp.words[0].data(), argv.data()); + exit(execvp(exp.words[0].data(), argv.data())); } else { // Parent: monitor the pidfd by adding ourselves to the event loop now eventLoop.AddObject(IoObject::Ptr(shared_from_this())); @@ -60,8 +60,8 @@ namespace nanosm { void Process::OnReady(int eventMask) { // In our case, any readiness signaled by the pidfd means the process exited - // so this will never block (or really, wait). - waitid(P_PIDFD, pidFd, &siginfo, WNOHANG); + // so this will never block (or really, wait). But in the case that it does + auto res = waitid(P_PIDFD, pidFd, &siginfo, WNOHANG | WEXITED); // Post a callback to call the user's exit callback (if one exists) eventLoop.Post([self = shared_from_this()]() {