Kernel: Implement process stopping and continuing
This commit is contained in:
@@ -188,6 +188,9 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags);
|
||||
|
||||
void set_stopped(bool stopped, int signal);
|
||||
void wait_while_stopped();
|
||||
|
||||
static BAN::ErrorOr<void> kill(pid_t pid, int signal);
|
||||
BAN::ErrorOr<long> sys_kill(pid_t pid, int signal);
|
||||
BAN::ErrorOr<long> sys_sigaction(int signal, const struct sigaction* act, struct sigaction* oact);
|
||||
@@ -299,12 +302,11 @@ namespace Kernel
|
||||
}
|
||||
|
||||
private:
|
||||
struct ChildExitStatus
|
||||
struct ChildWaitStatus
|
||||
{
|
||||
pid_t pid { 0 };
|
||||
pid_t pgrp { 0 };
|
||||
int exit_code { 0 };
|
||||
bool exited { false };
|
||||
pid_t pid { 0 };
|
||||
pid_t pgrp { 0 };
|
||||
BAN::Optional<int> status;
|
||||
};
|
||||
|
||||
Credentials m_credentials;
|
||||
@@ -320,6 +322,9 @@ namespace Kernel
|
||||
|
||||
mutable Mutex m_process_lock;
|
||||
|
||||
BAN::Atomic<bool> m_stopped { false };
|
||||
ThreadBlocker m_stop_blocker;
|
||||
|
||||
VirtualFileSystem::File m_working_directory;
|
||||
VirtualFileSystem::File m_root_file;
|
||||
|
||||
@@ -344,8 +349,9 @@ namespace Kernel
|
||||
BAN::Vector<BAN::String> m_environ;
|
||||
BAN::String m_executable;
|
||||
|
||||
BAN::Vector<ChildExitStatus> m_child_exit_statuses;
|
||||
ThreadBlocker m_child_exit_blocker;
|
||||
BAN::Vector<ChildWaitStatus> m_child_wait_statuses;
|
||||
SpinLock m_child_wait_lock;
|
||||
ThreadBlocker m_child_wait_blocker;
|
||||
|
||||
BAN::Atomic<bool> m_is_exiting { false };
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<void> initialize_userspace(vaddr_t entry, BAN::Span<BAN::String> argv, BAN::Span<BAN::String> envp, BAN::Span<LibELF::AuxiliaryVector> auxv);
|
||||
|
||||
// Returns true, if thread is going to trigger signal
|
||||
bool is_interrupted_by_signal() const;
|
||||
bool is_interrupted_by_signal(bool skip_stop_and_cont = false) const;
|
||||
|
||||
// Returns true if pending signal can be added to thread
|
||||
bool can_add_signal_to_execute() const;
|
||||
@@ -63,6 +63,13 @@ namespace Kernel
|
||||
void add_signal(int signal);
|
||||
void set_suspend_signal_mask(uint64_t sigmask);
|
||||
|
||||
static bool is_stopping_signal(int signal);
|
||||
static bool is_continuing_signal(int signal);
|
||||
static bool is_terminating_signal(int signal);
|
||||
static bool is_abnormal_terminating_signal(int signal);
|
||||
static bool is_realtime_signal(int signal);
|
||||
bool will_exit_because_of_signal() const;
|
||||
|
||||
BAN::ErrorOr<void> sigaltstack(const stack_t* ss, stack_t* oss);
|
||||
|
||||
// blocks current thread and returns either on unblock, eintr, spuriously or after timeout
|
||||
|
||||
Reference in New Issue
Block a user