i386/87208: /dev/cuad[0/1] bad file descriptor error during
mgetty read
Bruce Evans
bde at zeta.org.au
Wed Oct 19 21:10:58 PDT 2005
On Tue, 18 Oct 2005, HASHI Hiroaki wrote:
> In this case, mgetty open a /dev/cuad? and dup(2) to stdin.
>
> int fd;
>
> fd = open(devname, O_RDWR | O_NDELAY | O_NOCTTY );
>
> /* make new fd == stdin if it isn't already */
>
> if (fd > 0)
> {
> (void) close(0);
> ---> if (dup(fd) != 0)
> {
> lprintf( L_FATAL, "mod: cannot make %s stdin", devname );
> return ERROR;
> }
> }
>
> Bad dup() was not return descriptor 0.
>
> Is this a dup(3)'s bug?
> (or imcompatible change?)
Looks like a bug in dup(2). dup(2) is documented to return the "lowest
numbered descriptor not in use by the process", and the close(0) should
ensure that descriptor 0 is not in use. The only visible bug in mgetty
is that it ignores errors in close(0); this breaks mainly the error
reporting.
Bruce
More information about the freebsd-i386
mailing list