mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
kevent: fix race on process exit event
This commit is contained in:
parent
d0d22529f9
commit
b0b0226064
|
|
@ -65,6 +65,7 @@ struct Process final {
|
|||
sint budgetId{1};
|
||||
bool isInSandbox = false;
|
||||
EventEmitter event;
|
||||
std::optional<sint> exitStatus;
|
||||
|
||||
std::uint32_t sdkVersion = -1;
|
||||
std::uint64_t nextTlsSlot = 1;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,11 @@ static SysResult keventChange(KQueue *kq, KEvent &change, Thread *thread) {
|
|||
std::unique_lock lock(process->event.mutex);
|
||||
process->event.notes.insert(&*nodeIt);
|
||||
nodeIt->linked = process;
|
||||
if ((change.fflags & orbis::kNoteExit) != 0 && process->exitStatus.has_value()) {
|
||||
note.event.data = *process->exitStatus;
|
||||
note.triggered = true;
|
||||
kq->cv.notify_all(kq->mtx);
|
||||
}
|
||||
} else if (change.filter == kEvFiltRead ||
|
||||
change.filter == kEvFiltWrite) {
|
||||
auto fd = thread->tproc->fileDescriptors.get(change.ident);
|
||||
|
|
|
|||
|
|
@ -702,6 +702,7 @@ orbis::SysResult nmount(orbis::Thread *thread, orbis::ptr<orbis::IoVec> iovp,
|
|||
|
||||
orbis::SysResult exit(orbis::Thread *thread, orbis::sint status) {
|
||||
std::printf("Requested exit with status %d\n", status);
|
||||
thread->tproc->exitStatus = status;
|
||||
thread->tproc->event.emit(orbis::kEvFiltProc, orbis::kNoteExit, status);
|
||||
std::exit(status);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue