Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jun 1999 17:09:49 -0700 (PDT)
From:      Allan Saddi <asaddi@philosophysw.com>
To:        freebsd-emulation@freebsd.org
Subject:   Bug in linux fcntl syscall?
Message-ID:  <Pine.BSF.4.10.9906111638550.23239-100000@shell2.ba.best.com>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9906111638550.23239-100000>