From 0bf4c7c5641a826d0d550fa1702ba2dfdf751c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 5 Apr 2005 12:39:27 +0000 Subject: [PATCH] The shortcut if you call setpgid(0, 0) is now also taken if you call it with the IDs for the calling team, ie. setpgid(getpid(), getpid()) because it's essentially the same thing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12247 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/team.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/kernel/core/team.c b/src/kernel/core/team.c index b798fcf1a1..b165c693d3 100644 --- a/src/kernel/core/team.c +++ b/src/kernel/core/team.c @@ -2058,9 +2058,9 @@ _user_process_info(pid_t process, int32 which) pid_t _user_setpgid(pid_t processID, pid_t groupID) { - struct team *currentTeam = thread_get_current_thread()->team; + struct thread *thread = thread_get_current_thread(); + struct team *currentTeam = thread->team; struct process_group *group = NULL, *freeGroup = NULL; - struct thread *thread; struct team *team; cpu_status state; team_id teamID = -1; @@ -2069,16 +2069,18 @@ _user_setpgid(pid_t processID, pid_t groupID) if (groupID < 0) return B_BAD_VALUE; - if (processID == 0) { - // get our own process ID + if (processID == 0) processID = currentTeam->main_thread->id; + + if (processID == currentTeam->main_thread->id) { + // we set our own group teamID = currentTeam->id; // we must not change our process group ID if we're a group leader if (is_process_group_leader(currentTeam)) { // if the group ID was not specified, we just return the // process ID as we already are a process group leader - if (groupID == 0) + if (groupID == 0 || groupID == processID) return processID; return B_NOT_ALLOWED;