Fork me on GitHub

root/kernel/syscalls/getpgid.c

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

DEFINITIONS

This source file includes following definitions.
  1. sys_getpgid

   1 /*
   2  * fiwix/kernel/syscalls/getpgid.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_getpgid(__pid_t pid)
  18 {
  19         struct proc *p;
  20 
  21 #ifdef __DEBUG__
  22         printk("(pid %d) sys_getpgid(%d)\n", current->pid, pid);
  23 #endif /*__DEBUG__ */
  24 
  25         if(pid < 0) {
  26                 return -EINVAL;
  27         }
  28         if(!pid) {
  29                 return current->pgid;
  30         }
  31         FOR_EACH_PROCESS(p) {
  32                 if(p->pid == pid) {
  33                         return p->pgid;
  34                 }
  35                 p = p->next;
  36         }
  37         return -ESRCH;
  38 }

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