Add pidfd_open syscall helpers

This commit is contained in:
wannacu 2022-07-15 13:44:07 +08:00
parent 8d60d70553
commit 0dd03e9cb6
4 changed files with 23 additions and 1 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ out/
.vscode/
.vs/
*.pyc
.cache

View File

@ -59,3 +59,16 @@ if (compiles)
add_definitions(-DHAS_SYSCALL_RENAMEAT2=1)
endif ()
check_cxx_source_compiles(
"
#include <stdio.h>
#include <syscall.h>
int main() {
return ::syscall(SYS_pidfd_open, ::getpid(), 0);
}"
compiles)
if (compiles)
message(STATUS "Has pidfd_open helper")
add_definitions(-DHAS_SYSCALL_PIDFD_OPEN=1)
endif ()

View File

@ -79,5 +79,12 @@ inline int32_t renameat2(int olddirfd, const char *oldpath, int newdirfd, const
#endif
}
inline int32_t pidfd_open(pid_t pid, unsigned int flags) {
#if defined(DHAS_SYSCALL_PIDFD_OPEN) && DHAS_SYSCALL_PIDFD_OPEN
return ::syscall(SYS_pidfd_open, pid_t pid, unsigned int flags);
#else
return -1;
#endif
}
}

View File

@ -1,3 +1,4 @@
#include "FEXHeaderUtils/Syscalls.h"
#include "Logger.h"
#include "SquashFS.h"
@ -398,7 +399,7 @@ namespace ProcessPipe {
break;
}
case FEXServerClient::PacketType::TYPE_GET_PID_FD: {
int FD = ::syscall(SYS_pidfd_open, ::getpid(), 0);
int FD = FHU::Syscalls::pidfd_open(::getpid(), 0);
SendFDSuccessPacket(Socket, FD);