mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
Kernel: Move process parent PID into protected data :^)
This commit is contained in:
parent
d677a73b0e
commit
3d27269f13
4 changed files with 6 additions and 6 deletions
|
@ -238,7 +238,6 @@ Process::Process(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gi
|
||||||
, m_executable(move(executable))
|
, m_executable(move(executable))
|
||||||
, m_cwd(move(cwd))
|
, m_cwd(move(cwd))
|
||||||
, m_tty(tty)
|
, m_tty(tty)
|
||||||
, m_ppid(ppid)
|
|
||||||
, m_wait_block_condition(*this)
|
, m_wait_block_condition(*this)
|
||||||
{
|
{
|
||||||
m_protected_data = KBuffer::try_create_with_size(sizeof(ProtectedData));
|
m_protected_data = KBuffer::try_create_with_size(sizeof(ProtectedData));
|
||||||
|
@ -247,6 +246,7 @@ Process::Process(RefPtr<Thread>& first_thread, const String& name, uid_t uid, gi
|
||||||
{
|
{
|
||||||
MutableProtectedData protected_data { *this };
|
MutableProtectedData protected_data { *this };
|
||||||
protected_data->pid = allocate_pid();
|
protected_data->pid = allocate_pid();
|
||||||
|
protected_data->ppid = ppid;
|
||||||
protected_data->uid = uid;
|
protected_data->uid = uid;
|
||||||
protected_data->gid = gid;
|
protected_data->gid = gid;
|
||||||
protected_data->euid = uid;
|
protected_data->euid = uid;
|
||||||
|
@ -518,7 +518,7 @@ void Process::finalize()
|
||||||
|
|
||||||
{
|
{
|
||||||
// FIXME: PID/TID BUG
|
// FIXME: PID/TID BUG
|
||||||
if (auto parent_thread = Thread::from_tid(m_ppid.value())) {
|
if (auto parent_thread = Thread::from_tid(ppid().value())) {
|
||||||
if (!(parent_thread->m_signal_action_data[SIGCHLD].flags & SA_NOCLDWAIT))
|
if (!(parent_thread->m_signal_action_data[SIGCHLD].flags & SA_NOCLDWAIT))
|
||||||
parent_thread->send_signal(SIGCHLD, this);
|
parent_thread->send_signal(SIGCHLD, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ class Process
|
||||||
|
|
||||||
struct ProtectedData {
|
struct ProtectedData {
|
||||||
ProcessID pid { 0 };
|
ProcessID pid { 0 };
|
||||||
|
ProcessID ppid { 0 };
|
||||||
SessionID sid { 0 };
|
SessionID sid { 0 };
|
||||||
uid_t euid { 0 };
|
uid_t euid { 0 };
|
||||||
gid_t egid { 0 };
|
gid_t egid { 0 };
|
||||||
|
@ -209,7 +210,7 @@ public:
|
||||||
gid_t gid() const { return protected_data().gid; }
|
gid_t gid() const { return protected_data().gid; }
|
||||||
uid_t suid() const { return protected_data().suid; }
|
uid_t suid() const { return protected_data().suid; }
|
||||||
gid_t sgid() const { return protected_data().sgid; }
|
gid_t sgid() const { return protected_data().sgid; }
|
||||||
ProcessID ppid() const { return m_ppid; }
|
ProcessID ppid() const { return protected_data().ppid; }
|
||||||
|
|
||||||
bool is_dumpable() const { return m_dumpable; }
|
bool is_dumpable() const { return m_dumpable; }
|
||||||
void set_dumpable(bool dumpable) { m_dumpable = dumpable; }
|
void set_dumpable(bool dumpable) { m_dumpable = dumpable; }
|
||||||
|
@ -587,7 +588,6 @@ private:
|
||||||
|
|
||||||
RefPtr<TTY> m_tty;
|
RefPtr<TTY> m_tty;
|
||||||
|
|
||||||
ProcessID m_ppid { 0 };
|
|
||||||
mode_t m_umask { 022 };
|
mode_t m_umask { 022 };
|
||||||
|
|
||||||
bool m_dumpable { true };
|
bool m_dumpable { true };
|
||||||
|
|
|
@ -36,7 +36,7 @@ KResultOr<int> Process::sys$disown(ProcessID pid)
|
||||||
return ESRCH;
|
return ESRCH;
|
||||||
if (process->ppid() != this->pid())
|
if (process->ppid() != this->pid())
|
||||||
return ECHILD;
|
return ECHILD;
|
||||||
process->m_ppid = 0;
|
MutableProtectedData(*this)->ppid = 0;
|
||||||
process->disowned_by_waiter(*this);
|
process->disowned_by_waiter(*this);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ KResultOr<pid_t> Process::sys$getpid()
|
||||||
KResultOr<pid_t> Process::sys$getppid()
|
KResultOr<pid_t> Process::sys$getppid()
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
return m_ppid.value();
|
return protected_data().ppid.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<int> Process::sys$get_process_name(Userspace<char*> buffer, size_t buffer_size)
|
KResultOr<int> Process::sys$get_process_name(Userspace<char*> buffer, size_t buffer_size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue