@@ -54,29 +54,44 @@ int sys_futex_wake(int *pointer) {
54
54
}
55
55
56
56
int sys_waitpid (pid_t pid, int *status, int flags, struct rusage *ru, pid_t *ret_pid) {
57
- SignalGuard sguard;
57
+ if (ru) {
58
+ mlibc::infoLogger () << " mlibc: struct rusage in sys_waitpid is unsupported" << frg::endlog;
59
+ return ENOSYS;
60
+ }
61
+
62
+ HelHandle cancel_handle;
63
+ HEL_CHECK (helCreateOneshotEvent (&cancel_handle));
64
+ helix::UniqueDescriptor cancel_event{cancel_handle};
58
65
59
66
managarm::posix::CntRequest<MemoryAllocator> req (getSysdepsAllocator ());
60
67
req.set_request_type (managarm::posix::CntReqType::WAIT);
61
68
req.set_pid (pid);
62
69
req.set_flags (flags);
63
70
64
- auto [offer, send_head, recv_resp] = exchangeMsgsSync (
71
+ auto [offer, send_head, push_descriptor, recv_resp] = exchangeMsgsSyncCancellable (
65
72
getPosixLane (),
73
+ cancel_handle,
66
74
helix_ng::offer (
67
- helix_ng::sendBragiHeadOnly (req, getSysdepsAllocator ()), helix_ng::recvInline ()
75
+ helix_ng::sendBragiHeadOnly (req, getSysdepsAllocator ()),
76
+ helix_ng::pushDescriptor (cancel_event),
77
+ helix_ng::recvInline ()
68
78
)
69
79
);
70
80
71
81
HEL_CHECK (offer.error ());
72
82
HEL_CHECK (send_head.error ());
83
+ HEL_CHECK (push_descriptor.error ());
73
84
HEL_CHECK (recv_resp.error ());
74
85
75
86
managarm::posix::SvrResponse<MemoryAllocator> resp (getSysdepsAllocator ());
76
87
resp.ParseFromArray (recv_resp.data (), recv_resp.length ());
77
88
if (resp.error () == managarm::posix::Errors::ILLEGAL_ARGUMENTS) {
78
89
return EINVAL;
79
90
}
91
+ if (resp.error () == managarm::posix::Errors::INTERRUPTED) {
92
+ mlibc::infoLogger () << " returning EINT" << frg::endlog;
93
+ return EINTR;
94
+ }
80
95
__ensure (resp.error () == managarm::posix::Errors::SUCCESS);
81
96
if (status)
82
97
*status = resp.mode ();
0 commit comments