mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
kernel: implement sys_fork
This commit is contained in:
parent
b32b4e1c60
commit
d54fc9764f
|
|
@ -30,4 +30,22 @@ struct thr_param {
|
|||
ptr<char> name;
|
||||
ptr<void> spare[2];
|
||||
};
|
||||
|
||||
static constexpr auto RFFDG = 1 << 2; // copy fd table
|
||||
static constexpr auto RFPROC = 1 << 4; // change child (else changes curproc)
|
||||
static constexpr auto RFMEM = 1 << 5; // share `address space'
|
||||
static constexpr auto RFNOWAIT = 1 << 6; // give child to init
|
||||
static constexpr auto RFCFDG = 1 << 12; // close all fds, zero fd table
|
||||
static constexpr auto RFSIGSHARE = 1 << 14; // share signal handlers
|
||||
static constexpr auto RFLINUXTHPN =
|
||||
1 << 16; // do linux clone exit parent notification
|
||||
static constexpr auto RFTSIGZMB =
|
||||
1 << 19; // select signal for exit parent notification
|
||||
static constexpr auto RFTSIGSHIFT =
|
||||
20; // selected signal number is in bits 20-27
|
||||
static constexpr auto RFTSIGMASK = 0xFF;
|
||||
static constexpr auto RFPROCDESC = 1 << 28; // return a process descriptor
|
||||
static constexpr auto RFPPWAIT =
|
||||
1 << 31; // parent sleeps until child exits (vfork)
|
||||
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@
|
|||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
orbis::SysResult orbis::sys_fork(Thread *thread) { return ErrorCode::NOSYS; }
|
||||
orbis::SysResult orbis::sys_fork(Thread *thread) {
|
||||
if (auto fork = thread->tproc->ops->fork) {
|
||||
return fork(thread, RFFDG | RFPROC);
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_pdfork(Thread *thread, ptr<sint> fdp, sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ orbis::SysResult nmount(orbis::Thread *thread, orbis::ptr<orbis::IoVec> iovp,
|
|||
}
|
||||
|
||||
if (fstype == "nullfs") {
|
||||
ORBIS_RET_ON_ERROR(rx::vfs::unlink(fspath, thread));
|
||||
rx::vfs::unlinkAll(fspath, thread);
|
||||
return rx::vfs::createSymlink(target, fspath, thread);
|
||||
}
|
||||
|
||||
|
|
@ -788,7 +788,7 @@ SysResult fork(Thread *thread, slong flags) {
|
|||
}
|
||||
}
|
||||
|
||||
if (false) {
|
||||
if (flags & RFFDG) {
|
||||
std::lock_guard lock(thread->tproc->fileDescriptors.mutex);
|
||||
for (auto [id, mod] : thread->tproc->fileDescriptors) {
|
||||
if (!process->fileDescriptors.insert(id, mod)) {
|
||||
|
|
@ -827,6 +827,8 @@ SysResult fork(Thread *thread, slong flags) {
|
|||
dup2(logFd, 1);
|
||||
dup2(logFd, 2);
|
||||
|
||||
::close(logFd);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue