summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-04 13:51:11 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-04 18:17:16 +0200
commit7de831efc65993c44c9e87342a08f6a122250794 (patch)
treec13e3ae3fa83693eec89be1a1414ebd7ef582b9d /Libraries
parent83a4fbf5481322989e2e4a83a13a3fc570130c9a (diff)
downloadserenity-7de831efc65993c44c9e87342a08f6a122250794.zip
Kernel+LibC: Add sys$disown() for disowning child processes
This syscall allows a parent process to disown a child process, setting its parent PID to 0. Unparented processes are automatically reaped by the kernel upon exit, and no sys$waitid() is required. This will make it much nicer to do spawn-and-forget which is common in the GUI environment.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibC/serenity.cpp6
-rw-r--r--Libraries/LibC/serenity.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibC/serenity.cpp b/Libraries/LibC/serenity.cpp
index 68e10accb0..5837aee15f 100644
--- a/Libraries/LibC/serenity.cpp
+++ b/Libraries/LibC/serenity.cpp
@@ -30,6 +30,12 @@
extern "C" {
+int disown(pid_t pid)
+{
+ int rc = syscall(SC_disown, pid);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
int module_load(const char* path, size_t path_length)
{
int rc = syscall(SC_module_load, path, path_length);
diff --git a/Libraries/LibC/serenity.h b/Libraries/LibC/serenity.h
index 6ed6bba428..55423f13c2 100644
--- a/Libraries/LibC/serenity.h
+++ b/Libraries/LibC/serenity.h
@@ -31,6 +31,8 @@
__BEGIN_DECLS
+int disown(pid_t);
+
int shbuf_create(int, void** buffer);
int shbuf_allow_pid(int, pid_t peer_pid);
int shbuf_allow_all(int);