Skip to content

Commit 7b53d8c

Browse files
committed
sysdeps/managarm: implement sys_pidfd_open
1 parent 178ecef commit 7b53d8c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

sysdeps/managarm/generic/file.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,34 @@ int sys_signalfd_create(const sigset_t *masks, int flags, int *fd) {
13371337
return 0;
13381338
}
13391339

1340+
int sys_pidfd_open(pid_t pid, unsigned int flags, int *outfd) {
1341+
SignalGuard sguard;
1342+
1343+
managarm::posix::PidfdOpenRequest<MemoryAllocator> req(getSysdepsAllocator());
1344+
req.set_pid(pid);
1345+
req.set_flags(flags);
1346+
1347+
auto [offer, send_req, recv_resp] = exchangeMsgsSync(
1348+
getPosixLane(),
1349+
helix_ng::offer(
1350+
helix_ng::sendBragiHeadOnly(req, getSysdepsAllocator()), helix_ng::recvInline()
1351+
)
1352+
);
1353+
1354+
HEL_CHECK(offer.error());
1355+
HEL_CHECK(send_req.error());
1356+
HEL_CHECK(recv_resp.error());
1357+
1358+
managarm::posix::PidfdOpenResponse<MemoryAllocator> resp(getSysdepsAllocator());
1359+
resp.ParseFromArray(recv_resp.data(), recv_resp.length());
1360+
1361+
if (resp.error() != managarm::posix::Errors::SUCCESS)
1362+
return resp.error() | toErrno;
1363+
1364+
*outfd = resp.fd();
1365+
return 0;
1366+
}
1367+
13401368
int sys_reboot(int command) {
13411369
if (command != RB_POWER_OFF && command != RB_AUTOBOOT) {
13421370
mlibc::infoLogger(

0 commit comments

Comments
 (0)