NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/44950: fcntl(F_MAXFD) returns bogus values

The following reply was made to PR kern/44950; it has been noted by GNATS.

From: Jukka Ruohonen <>
To: Martin Husemann <>
Cc:, Julio Merino <>
Subject: Re: kern/44950: fcntl(F_MAXFD) returns bogus values
Date: Wed, 11 May 2011 10:55:08 +0300

 On Wed, May 11, 2011 at 09:43:52AM +0200, Martin Husemann wrote:
 > Besides that, this is more of a (k)sh bug, which seems to be pretty common
 > for bourne shells in general (or so says the internet, the fd in use seems
 > to vary, typically 19 instead of 9). The shell keeps an fd open when it execs
 > scripts from a file.
 I don't quite understand the following behavior of fcntl(2) either. Why the
 assertion goes off?
 #include <sys/wait.h>
 #include <assert.h>
 #include <fcntl.h>
 #include <unistd.h>
        pid_t pid;
        int i, sta;
        pid = fork();
        assert(pid >= 0);
        if (pid == 0) {
                for (i = 0; i < 1024; i++)
                _exit(fcntl(0, F_MAXFD));
        assert(WEXITSTATUS(sta) != 255);
        return 0;

Home | Main Index | Thread Index | Old Index