Date: Tue, 18 Oct 2005 09:33:55 GMT From: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp> To: freebsd-i386@FreeBSD.org Subject: Re: i386/87208: /dev/cuad[0/1] bad file descriptor error during mgetty read Message-ID: <200510180933.j9I9XtQu026284@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR i386/87208; it has been noted by GNATS. From: HASHI Hiroaki <hashiz@tomba.cskk-sv.co.jp> To: bug-followup@FreeBSD.org, norbert@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) . .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510180933.j9I9XtQu026284>