]> git.corax.cc Git - corax/commitdiff
Implement process_detach() method, to create a new session for a process, i.e. detach...
authorMatthias Kruk <m@m10k.eu>
Mon, 4 Nov 2019 08:35:24 +0000 (17:35 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 4 Nov 2019 08:35:24 +0000 (17:35 +0900)
include/corax/ipc.h
kernel/core/posixcall.c
kernel/core/process.c
kernel/include/process.h

index 2e916f42733aa3cbd06e31ae22a1446212fdd8ec..90b911f53460af98ebb91b061afa5055df2406ff 100644 (file)
@@ -15,4 +15,7 @@ struct cxmsg {
 
 #define cm_data CM_dat.CM_data
 
+#define PID_INIT 1
+#define PID_UNIX 10
+
 #endif /* __CORAX_IPC_H */
index 781c8896e4c73ccdabf287ee9dc59ceed9ed508b..34b29264ed53046e212f4ff2956bc829ea4003cd 100644 (file)
@@ -64,7 +64,33 @@ int sys_waitpid(pid_t pid, int *status, int options)
 
 int sys_setsid(void)
 {
-       return(-ENOSYS);
+       process_t *cproc;
+       int ret_val;
+
+       /*
+        * This call should basically just detach the process from its
+        * parent, so it can continue after the parent process has ended.
+        */
+
+       ret_val = -EFAULT;
+       cproc = process_get_current();
+
+       if(cproc) {
+               /*
+                * At this point there is nothing that needs to be done here. Maybe
+                * in the future there will be more that needs to be done.
+                */
+
+#if 0
+               process_t *pproc;
+
+               pproc = process_lookup(cproc->p_pid);
+#endif /* 0 */
+
+               ret_val = process_detach(cproc);
+       }
+
+       return(ret_val);
 }
 
 int sys_posixcall(stack_frame_t *stk)
index cb4699a484ebc52b39eb725944fb13b7085a3755..a909903243d7ef802d3d027b32690cd114d15b07 100644 (file)
@@ -558,3 +558,17 @@ int process_fork(int v)
 
        return(ret_val);
 }
+
+int process_detach(process_t *proc)
+{
+       int ret_val;
+
+       ret_val = -EINVAL;
+
+       if(proc) {
+               proc->p_pid = PID_INIT;
+               ret_val = 0;
+       }
+
+       return(ret_val);
+}
index 480e2e08e7254f6f4ca155650120f007eafa1101..4ac66d2a2579d1bddbb7486bd33ac233bc615354 100644 (file)
@@ -51,5 +51,6 @@ void*         process_get_tasks(process_t*);
 pid_t         process_get_id(process_t*);
 int           process_exit(process_t*, int);
 int           process_fork(int);
+int           process_detach(process_t*);
 
 #endif /* __PROCESS_H */