Browse Source

kernel: setsid should set pgid=pid

K. Lange 2 years ago
parent
commit
e8ec1cb6c3
3 changed files with 4 additions and 3 deletions
  1. 1 0
      apps/login.c
  2. 1 2
      apps/sh.c
  3. 2 1
      kernel/sys/syscall.c

+ 1 - 0
apps/login.c

@@ -145,6 +145,7 @@ do_fork:
 	if (getpid() != pid) {
 		ioctl(STDIN_FILENO, IOCTLTTYLOGIN, &uid);
 		setuid(uid);
+		setsid();
 		toaru_auth_set_vars();
 		char * args[] = {
 			getenv("SHELL"),

+ 1 - 2
apps/sh.c

@@ -1553,8 +1553,7 @@ int main(int argc, char ** argv) {
 
 	shell_interactive = 1;
 
-	setpgid(0,0);
-	my_pgid = getuid();
+	my_pgid = getpgid(0);
 	signal(SIGTTOU, SIG_IGN);
 	signal(SIGTTIN, SIG_IGN);
 

+ 2 - 1
kernel/sys/syscall.c

@@ -940,7 +940,8 @@ static int sys_setsid(void) {
 		return -EPERM;
 	}
 	current_process->session = current_process->group;
-	return current_process->group;
+	current_process->job = current_process->group;
+	return current_process->session;
 }
 
 static int sys_setpgid(pid_t pid, pid_t pgid) {