Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/kernel/syscalls/getsid.c 3 * 4 * Copyright 2018-2021, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #include <fiwix/types.h> 9 #include <fiwix/process.h> 10 #include <fiwix/sched.h> 11 #include <fiwix/errno.h> 12 13 #ifdef __DEBUG__ 14 #include <fiwix/stdio.h> 15 #endif /*__DEBUG__ */ 16 17 int sys_getsid(__pid_t pid) 18 { 19 struct proc *p; 20 21 #ifdef __DEBUG__ 22 printk("(pid %d) sys_getsid(%d)\n", current->pid, pid); 23 #endif /*__DEBUG__ */ 24 25 if(pid < 0) { 26 return -EINVAL; 27 } 28 if(!pid) { 29 return current->sid; 30 } 31 32 FOR_EACH_PROCESS(p) { 33 if(p->pid == pid) { 34 return p->sid; 35 } 36 p = p->next; 37 } 38 return -ESRCH; 39 }