Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 2000 21:31:42 +0200 (CEST)
From:      Christian Weisgerber <naddy@mips.inka.de>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/21402: Linuxulator: getpgid(0) fails
Message-ID:  <200009191931.e8JJVg208733@ganerc.mips.inka.de>

next in thread | raw e-mail | index | archive | help

>Number:         21402
>Category:       kern
>Synopsis:       Linuxulator: getpgid(0) fails
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 19 13:00:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Christian Weisgerber
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:

COMPAT_LINUX

>Description:

Under the Linux syscall compatibility layer, getpgid(0) fails with
ESRCH rather than returning the process group ID of the current
process.

This can be fixed easily in sys/compat/linux/linux_misc.c:linux_getpgid().
However, as far as I can tell, the semantics of getpgid() are
exactly the same for BSD, Linux, and POSIX.  The only functional
difference between our native getpgid() and linux_getpgid() I can
detect is that the latter fails to handle being called with 0.

Therefore I suggest that linux_getpgid() is dropped entirely and
the Linux system call #132 passed on directly to getpgid(), which is
both simpler and more correct.

>How-To-Repeat:

>Fix:

--- sys/compat/linux/linux_misc.c.orig	Tue Sep 19 14:10:58 2000
+++ sys/compat/linux/linux_misc.c	Tue Sep 19 14:11:37 2000
@@ -524,24 +524,6 @@
     return error;
 }
 
-int
-linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
-{
-    struct proc *curp;
-
-#ifdef DEBUG
-    printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid);
-#endif
-    if (args->pid != p->p_pid) {
-	if (!(curp = pfind(args->pid)))
-	    return ESRCH;
-    }
-    else
-	curp = p;
-    p->p_retval[0] = curp->p_pgid;
-    return 0;
-}
-
 int     
 linux_mremap(struct proc *p, struct linux_mremap_args *args)
 {
--- sys/i386/linux/syscalls.master.orig	Tue Sep 19 14:14:31 2000
+++ sys/i386/linux/syscalls.master	Tue Sep 19 14:16:24 2000
@@ -196,7 +196,7 @@
 129	STD	LINUX	{ int linux_delete_module(void); }
 130	STD	LINUX	{ int linux_get_kernel_syms(void); }
 131	STD	LINUX	{ int linux_quotactl(void); }
-132	STD	LINUX	{ int linux_getpgid(int pid); }
+132	NOPROTO	LINUX	{ int getpgid(int pid); }
 133	NOPROTO	LINUX	{ int fchdir(int fd); }
 134	STD	LINUX	{ int linux_bdflush(void); }
 135	STD	LINUX	{ int linux_sysfs(int option, u_long arg1, \

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009191931.e8JJVg208733>