2 * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 #include <syscall_process_info.h>
14 #include <errno_private.h>
17 #define RETURN_AND_SET_ERRNO(err) \
25 extern thread_id __main_thread_id
;
31 return getpgid(__main_thread_id
);
38 // this one returns the ID of the main thread
39 return __main_thread_id
;
46 return _kern_process_info(0, PARENT_ID
);
47 // this is not supposed to return an error value
54 pid_t session
= _kern_process_info(process
, SESSION_ID
);
56 RETURN_AND_SET_ERRNO(session
);
61 getpgid(pid_t process
)
63 pid_t group
= _kern_process_info(process
, GROUP_ID
);
65 RETURN_AND_SET_ERRNO(group
);
70 setpgid(pid_t process
, pid_t group
)
72 pid_t result
= _kern_setpgid(process
, group
);
76 RETURN_AND_SET_ERRNO(result
);
83 // setpgrp() never fails -- setpgid() fails when the process is a session
85 pid_t result
= _kern_setpgid(0, 0);
86 return result
>= 0 ? result
: getpgrp();
93 status_t status
= _kern_setsid();
95 RETURN_AND_SET_ERRNO(status
);