From owner-freebsd-emulation Fri Jun 11 17: 9:53 1999 Delivered-To: freebsd-emulation@freebsd.org Received: from shell2.ba.best.com (shell2.ba.best.com [206.184.139.133]) by hub.freebsd.org (Postfix) with ESMTP id D00CA14C2A for ; Fri, 11 Jun 1999 17:09:49 -0700 (PDT) (envelope-from asaddi@philosophysw.com) Received: from localhost (asaddi@localhost) by shell2.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id RAA27680 for ; Fri, 11 Jun 1999 17:09:49 -0700 (PDT) X-Authentication-Warning: shell2.ba.best.com: asaddi owned process doing -bs Date: Fri, 11 Jun 1999 17:09:49 -0700 (PDT) From: Allan Saddi X-Sender: asaddi@shell2.ba.best.com To: freebsd-emulation@freebsd.org Subject: Bug in linux fcntl syscall? Message-ID: Organization: Philosophy SoftWorks MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I decided to play around with the Linux version of TclPro 1.2 yesterday, since I found out my company had a site license for it. Anyway, what I found was that the installation program would hang on uzpln86 (the included unzip program). By searching the archives of this group, I found that Chris Timmons ran into a similar problem early this year (Re: TclPro for Linux eval). No solution appeared to have been found. I got around this problem by unzipping/installing the package myself and kludging the installation program. What I got was a relatively usable installation. However, the problem appeared again when I tried to use the GUI debugger (prodebug). prodebug would execute protclsh80 and just hang. No CPU usage, no I/O, nada. Today, after hours of truss'ing and strace'ing (on a RedHat 6 system), I discovered the problem. In linux_file.c, the function linux_fcntl: #ifdef DEBUG printf("Linux-emul(%d): fcntl(%d, %08x, *)\n", p->p_pid, args->fd, args->cmd); #endif fcntl_args.fd = args->fd; fcntl_args.arg = 0; switch (args->cmd) { ... case LINUX_F_SETFD: fcntl_args.cmd = F_SETFD; return fcntl(p, &fcntl_args); Notice that fcntl_args.arg is always 0. This keeps the F_SETFD call from ever setting the close-on-exec flag, which is precisely the problem. I patched the LINUX_F_SETFD case to set fcntl_args.arg to args->arg, and TclPro's prodebug now works fine. (The fcntl calls were made on fd's from a pipe. I surmise the child dup's these fd's and eventually closes them to signal to the parent that it is done. Since the original descriptors never closed [because close-on-exec wasn't set], this event never happened.) I would've filed a PR, but looking at the code, I see other cases that set/assign fcntl_args.arg explicitly. So I'm wondering if this was a design decision rather than a bug? (One of those feature vs. bugs things, I guess. ;) Oh yeah, my system: FreeBSD 3.2-STABLE #42: Wed May 19 17:48:38 PDT 1999 A bit stale, but I did check the CVS repository and there weren't any major updates to the linux emulator that would seemingly affect this. Any comments? -- Allan Saddi "The Earth is the cradle of mankind, asaddi@philosophysw.com but we cannot live in the cradle http://www.philosophysw.com/asaddi/ forever." - K.E. Tsiolkovsky To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message