Fork me on GitHub

root/kernel/syscalls/setsid.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_setsid

   1 /*
   2  * fiwix/kernel/syscalls/setsid.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/process.h>
   9 #include <fiwix/errno.h>
  10 #include <fiwix/string.h>
  11 
  12 #ifdef __DEBUG__
  13 #include <fiwix/stdio.h>
  14 #endif /*__DEBUG__ */
  15 
  16 int sys_setsid(void)
  17 {
  18         struct proc *p;
  19 
  20 #ifdef __DEBUG__
  21         printk("(pid %d) sys_setsid()\n", current->pid);
  22 #endif /*__DEBUG__ */
  23 
  24         if(PG_LEADER(current)) {
  25                 return -EPERM;
  26         }
  27         FOR_EACH_PROCESS(p) {   /* POSIX ANSI/IEEE Std 1003.1-1996 4.3.2 */
  28                 if(p != current && p->pgid == current->pid) {
  29                         return -EPERM;
  30                 }
  31                 p = p->next;
  32         }
  33 
  34         current->sid = current->pgid = current->pid;
  35         current->ctty = NULL;
  36         return current->sid;
  37 }

/* [previous][next][first][last][top][bottom][index][help] */