* Copyright 2002-2007, Axel DΓΆrfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <syscalls.h>
#include <syscall_process_info.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <errno_private.h>
#include <syscall_utils.h>
extern thread_id __main_thread_id;
pid_t
getpgrp(void)
{
return getpgid(__main_thread_id);
}
pid_t
getpid(void)
{
return __main_thread_id;
}
pid_t
getppid(void)
{
return _kern_process_info(0, PARENT_ID);
}
pid_t
getsid(pid_t process)
{
pid_t session = _kern_process_info(process, SESSION_ID);
RETURN_AND_SET_ERRNO(session);
}
pid_t
getpgid(pid_t process)
{
pid_t group = _kern_process_info(process, GROUP_ID);
RETURN_AND_SET_ERRNO(group);
}
int
setpgid(pid_t process, pid_t group)
{
pid_t result = _kern_setpgid(process, group);
if (result >= 0)
return 0;
RETURN_AND_SET_ERRNO(result);
}
pid_t
setpgrp(void)
{
pid_t result = _kern_setpgid(0, 0);
return result >= 0 ? result : getpgrp();
}
pid_t
setsid(void)
{
status_t status = _kern_setsid();
RETURN_AND_SET_ERRNO(status);
}