mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
Add getppid().
This commit is contained in:
parent
3024167cbd
commit
77fe8e8363
Notes:
sideshowbarker
2024-07-19 18:33:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/77fe8e83631
6 changed files with 22 additions and 8 deletions
|
@ -269,7 +269,7 @@ ByteBuffer procfs$summary()
|
|||
process->sid(),
|
||||
process->uid(),
|
||||
toString(process->state()),
|
||||
process->parentPID(),
|
||||
process->ppid(),
|
||||
process->timesScheduled(),
|
||||
process->number_of_open_file_descriptors(),
|
||||
process->tty() ? strrchr(process->tty()->ttyName().characters(), '/') + 1 : "n/a",
|
||||
|
|
|
@ -558,7 +558,7 @@ Process* Process::createKernelProcess(void (*e)(), String&& name)
|
|||
return process;
|
||||
}
|
||||
|
||||
Process::Process(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel ring, RetainPtr<VirtualFileSystem::Node>&& cwd, RetainPtr<VirtualFileSystem::Node>&& executable, TTY* tty, Process* fork_parent)
|
||||
Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring, RetainPtr<VirtualFileSystem::Node>&& cwd, RetainPtr<VirtualFileSystem::Node>&& executable, TTY* tty, Process* fork_parent)
|
||||
: m_name(move(name))
|
||||
, m_pid(next_pid++) // FIXME: RACE: This variable looks racy!
|
||||
, m_uid(uid)
|
||||
|
@ -570,7 +570,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel
|
|||
, m_cwd(move(cwd))
|
||||
, m_executable(move(executable))
|
||||
, m_tty(tty)
|
||||
, m_parentPID(parentPID)
|
||||
, m_ppid(ppid)
|
||||
{
|
||||
if (fork_parent) {
|
||||
m_sid = fork_parent->m_sid;
|
||||
|
@ -578,7 +578,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel
|
|||
} else {
|
||||
// FIXME: Use a ProcessHandle? Presumably we're executing *IN* the parent right now though..
|
||||
InterruptDisabler disabler;
|
||||
if (auto* parent = Process::fromPID(m_parentPID)) {
|
||||
if (auto* parent = Process::fromPID(m_ppid)) {
|
||||
m_sid = parent->m_sid;
|
||||
m_pgid = parent->m_pgid;
|
||||
}
|
||||
|
@ -1315,6 +1315,11 @@ pid_t Process::sys$getpid()
|
|||
return m_pid;
|
||||
}
|
||||
|
||||
pid_t Process::sys$getppid()
|
||||
{
|
||||
return m_ppid;
|
||||
}
|
||||
|
||||
pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
|
||||
{
|
||||
if (wstatus)
|
||||
|
|
|
@ -26,7 +26,7 @@ class Process : public InlineLinkedListNode<Process> {
|
|||
friend class InlineLinkedListNode<Process>;
|
||||
public:
|
||||
static Process* createKernelProcess(void (*entry)(), String&& name);
|
||||
static Process* create_user_process(const String& path, uid_t, gid_t, pid_t parentPID, int& error, Vector<String>&& arguments = Vector<String>(), Vector<String>&& environment = Vector<String>(), TTY* = nullptr);
|
||||
static Process* create_user_process(const String& path, uid_t, gid_t, pid_t ppid, int& error, Vector<String>&& arguments = Vector<String>(), Vector<String>&& environment = Vector<String>(), TTY* = nullptr);
|
||||
~Process();
|
||||
|
||||
static Vector<Process*> allProcesses();
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
gid_t gid() const { return m_gid; }
|
||||
uid_t euid() const { return m_euid; }
|
||||
gid_t egid() const { return m_egid; }
|
||||
pid_t parentPID() const { return m_parentPID; }
|
||||
pid_t ppid() const { return m_ppid; }
|
||||
|
||||
const FarPtr& farPtr() const { return m_farPtr; }
|
||||
|
||||
|
@ -103,6 +103,7 @@ public:
|
|||
uid_t sys$geteuid();
|
||||
gid_t sys$getegid();
|
||||
pid_t sys$getpid();
|
||||
pid_t sys$getppid();
|
||||
int sys$open(const char* path, int options);
|
||||
int sys$close(int fd);
|
||||
ssize_t sys$read(int fd, void* outbuf, size_t nread);
|
||||
|
@ -179,7 +180,7 @@ private:
|
|||
friend class MemoryManager;
|
||||
friend bool scheduleNewProcess();
|
||||
|
||||
Process(String&& name, uid_t, gid_t, pid_t parentPID, RingLevel, RetainPtr<VirtualFileSystem::Node>&& cwd = nullptr, RetainPtr<VirtualFileSystem::Node>&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
Process(String&& name, uid_t, gid_t, pid_t ppid, RingLevel, RetainPtr<VirtualFileSystem::Node>&& cwd = nullptr, RetainPtr<VirtualFileSystem::Node>&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
|
||||
void push_value_on_stack(dword);
|
||||
|
||||
|
@ -233,7 +234,7 @@ private:
|
|||
|
||||
LinearAddress m_return_from_signal_trampoline;
|
||||
|
||||
pid_t m_parentPID { 0 };
|
||||
pid_t m_ppid { 0 };
|
||||
|
||||
static void notify_waiters(pid_t waitee, int exit_status, int signal);
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2,
|
|||
return current->sys$getgid();
|
||||
case Syscall::SC_getpid:
|
||||
return current->sys$getpid();
|
||||
case Syscall::SC_getppid:
|
||||
return current->sys$getppid();
|
||||
case Syscall::SC_waitpid:
|
||||
return current->sys$waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
|
||||
case Syscall::SC_mmap:
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
__ENUMERATE_SYSCALL(dup) \
|
||||
__ENUMERATE_SYSCALL(dup2) \
|
||||
__ENUMERATE_SYSCALL(sigaction) \
|
||||
__ENUMERATE_SYSCALL(getppid) \
|
||||
|
||||
|
||||
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
|
||||
|
|
|
@ -44,6 +44,11 @@ pid_t getpid()
|
|||
return Syscall::invoke(Syscall::SC_getpid);
|
||||
}
|
||||
|
||||
pid_t getppid()
|
||||
{
|
||||
return Syscall::invoke(Syscall::SC_getppid);
|
||||
}
|
||||
|
||||
pid_t setsid()
|
||||
{
|
||||
int rc = Syscall::invoke(Syscall::SC_setsid);
|
||||
|
|
Loading…
Add table
Reference in a new issue