i386/87208: /dev/cuad[0/1] bad file descriptor error during
mgetty read
HASHI Hiroaki
hashiz at tomba.cskk-sv.co.jp
Tue Oct 18 02:33:56 PDT 2005
The following reply was made to PR i386/87208; it has been noted by GNATS.
From: HASHI Hiroaki <hashiz at tomba.cskk-sv.co.jp>
To: bug-followup at FreeBSD.org, norbert at feu-nrmf.ph
Cc:
Subject: Re: i386/87208: /dev/cuad[0/1] bad file descriptor error during
mgetty read
Date: Tue, 18 Oct 2005 18:30:58 +0900 (JST)
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?)
Workaround:
mgetty use dup2(3) instead of use dup(3).
dup2(fd, 0)
.
.
dup2(0, 1)
.
.
dup2(0, 2)
.
.
More information about the freebsd-i386
mailing list