summaryrefslogtreecommitdiff
path: root/Kernel/Process.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-06 10:46:40 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-06 10:56:41 +0100
commit153ea704af5e22c70e169f112e9df3e4cd9a6f11 (patch)
treee879dcf3decc9e162d3a4f0a746b05214b7899c1 /Kernel/Process.h
parent52d502e11f3207f2c5c36e7cc676f43f249fc351 (diff)
downloadserenity-153ea704af5e22c70e169f112e9df3e4cd9a6f11.zip
Add some basic signal support.
It only works for sending a signal to a process that's in userspace code. We implement reception by synthesizing a PUSHA+PUSHF in the receiving process (operating on values in the TSS.) The TSS CS:EIP is then rerouted to the signal handler and a tiny return trampoline is constructed in a dedicated region in the receiving process. Also hacked up /bin/kill to be able to send arbitrary signals (kill -N PID)
Diffstat (limited to 'Kernel/Process.h')
-rw-r--r--Kernel/Process.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 5c6365d9dd..ad8b1817ee 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -15,6 +15,13 @@ class PageDirectory;
class Region;
class Zone;
+struct SignalActionData {
+ LinearAddress handler_or_sigaction;
+ dword mask { 0 };
+ int flags { 0 };
+ LinearAddress restorer;
+};
+
class Process : public InlineLinkedListNode<Process> {
friend class InlineLinkedListNode<Process>;
public:
@@ -129,6 +136,7 @@ public:
int sys$getdtablesize();
int sys$dup(int oldfd);
int sys$dup2(int oldfd, int newfd);
+ int sys$sigaction(int signum, const Unix::sigaction* act, Unix::sigaction* old_act);
static void initialize();
@@ -162,6 +170,7 @@ public:
const FileHandle* file_descriptor(size_t i) const { return m_file_descriptors[i].ptr(); }
void send_signal(int signal, Process* sender);
+ void terminate_due_to_signal(int signal, Process* sender);
Process* fork(RegisterDump&);
int exec(const String& path, Vector<String>&& arguments, Vector<String>&& environment);
@@ -172,7 +181,7 @@ private:
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);
- void allocateLDT();
+ void push_value_on_stack(dword);
PageDirectory* m_page_directory { nullptr };
@@ -205,6 +214,7 @@ private:
int m_waiteeStatus { 0 };
int m_fdBlockedOnRead { -1 };
size_t m_max_open_file_descriptors { 16 };
+ SignalActionData m_signal_action_data[32];
RetainPtr<VirtualFileSystem::Node> m_cwd;
RetainPtr<VirtualFileSystem::Node> m_executable;
@@ -221,6 +231,8 @@ private:
// FIXME: Implement some kind of ASLR?
LinearAddress m_nextRegion;
+ LinearAddress m_return_from_signal_trampoline;
+
pid_t m_parentPID { 0 };
static void notify_waiters(pid_t waitee, int exit_status, int signal);