forked from Bananymous/banan-os
Kernel: Fix wait syscall to report status of exited children
This commit is contained in:
@@ -219,8 +219,6 @@ namespace Kernel
|
||||
// Load elf from a file
|
||||
static BAN::ErrorOr<BAN::UniqPtr<LibELF::LoadableELF>> load_elf_for_exec(const Credentials&, BAN::StringView file_path, const BAN::String& cwd, Kernel::PageTable&);
|
||||
|
||||
BAN::ErrorOr<int> block_until_exit(pid_t pid);
|
||||
|
||||
BAN::ErrorOr<void> validate_string_access(const char*);
|
||||
BAN::ErrorOr<void> validate_pointer_access_check(const void*, size_t);
|
||||
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t);
|
||||
@@ -255,12 +253,12 @@ namespace Kernel
|
||||
}
|
||||
|
||||
private:
|
||||
struct ExitStatus
|
||||
struct ChildExitStatus
|
||||
{
|
||||
ThreadBlocker thread_blocker;
|
||||
int exit_code { 0 };
|
||||
BAN::Atomic<bool> exited { false };
|
||||
BAN::Atomic<int> waiting { 0 };
|
||||
pid_t pid { 0 };
|
||||
pid_t pgrp { 0 };
|
||||
int exit_code { 0 };
|
||||
bool exited { false };
|
||||
};
|
||||
|
||||
Credentials m_credentials;
|
||||
@@ -292,7 +290,10 @@ namespace Kernel
|
||||
|
||||
bool m_is_userspace { false };
|
||||
userspace_info_t m_userspace_info;
|
||||
ExitStatus m_exit_status;
|
||||
|
||||
SpinLock m_child_exit_lock;
|
||||
BAN::Vector<ChildExitStatus> m_child_exit_statuses;
|
||||
ThreadBlocker m_child_exit_blocker;
|
||||
|
||||
bool m_has_called_exec { false };
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace Kernel
|
||||
bool add_signal(int signal);
|
||||
|
||||
// blocks current thread and returns either on unblock, eintr, spuriously or after timeout
|
||||
BAN::ErrorOr<void> sleep_or_eintr_ms(uint64_t ms) { return sleep_or_eintr_ns(ms * 1'000'000); }
|
||||
BAN::ErrorOr<void> sleep_or_eintr_ns(uint64_t ns);
|
||||
BAN::ErrorOr<void> block_or_eintr_indefinite(ThreadBlocker& thread_blocker);
|
||||
BAN::ErrorOr<void> block_or_eintr_or_timeout_ms(ThreadBlocker& thread_blocker, uint64_t timeout_ms, bool etimedout) { return block_or_eintr_or_timeout_ns(thread_blocker, timeout_ms * 1'000'000, etimedout); }
|
||||
BAN::ErrorOr<void> block_or_eintr_or_waketime_ms(ThreadBlocker& thread_blocker, uint64_t wake_time_ms, bool etimedout) { return block_or_eintr_or_waketime_ns(thread_blocker, wake_time_ms * 1'000'000, etimedout); }
|
||||
|
||||
Reference in New Issue
Block a user