Files
haiku-beta6/src/system/libroot/posix/unistd/process.c
T
Axel Dörfler 1beeb96080 setpgrp() returns a pid_t, not an int.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20008 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-29 13:31:24 +00:00

91 lines
1.2 KiB
C

/*
* Copyright 2002-2007, Axel Dörfler, [email protected]. 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>
#define RETURN_AND_SET_ERRNO(err) \
if (err < 0) { \
errno = err; \
return -1; \
} \
return err;
extern thread_id __main_thread_id;
pid_t
getpgrp(void)
{
return getpgid(__main_thread_id);
}
pid_t
getpid(void)
{
// this one returns the ID of the main thread
return __main_thread_id;
}
pid_t
getppid(void)
{
return _kern_process_info(0, PARENT_ID);
// this is not supposed to return an error value
}
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)
{
status_t status = _kern_setpgid(process, group);
RETURN_AND_SET_ERRNO(status);
}
pid_t
setpgrp(void)
{
return setpgid(0, 0);
}
pid_t
setsid(void)
{
status_t status = _kern_setsid();
RETURN_AND_SET_ERRNO(status);
}