From: Ulrich Drepper Date: Thu, 4 Oct 2007 21:54:22 +0000 (+0000) Subject: * login/login_tty.c (login_tty): The Linux kernel can return EBUSY X-Git-Tag: cvs/fedora-glibc-20071010T2047~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=174420d2bc39c611fbc09669490b96fc6cc81520;p=thirdparty%2Fglibc.git * login/login_tty.c (login_tty): The Linux kernel can return EBUSY for dup2 in case another thread races with the current one. Retry in this case. --- diff --git a/ChangeLog b/ChangeLog index e4ad3c8a90b..eed866ff589 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-10-04 Ulrich Drepper + * login/login_tty.c (login_tty): The Linux kernel can return EBUSY + for dup2 in case another thread races with the current one. Retry + in this case. + * misc/error.h: Remove support for use outside of libc. We have to include now. Include if possible. * misc/bits/error.h: New file. diff --git a/login/login_tty.c b/login/login_tty.c index 1bb1703267f..2ba276d4a96 100644 --- a/login/login_tty.c +++ b/login/login_tty.c @@ -31,6 +31,7 @@ static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include #include #include #include @@ -63,9 +64,12 @@ login_tty(fd) } } #endif - (void) dup2(fd, 0); - (void) dup2(fd, 1); - (void) dup2(fd, 2); + while (dup2(fd, 0) == -1 && errno == EBUSY) + ; + while (dup2(fd, 1) == -1 && errno == EBUSY) + ; + while (dup2(fd, 2) == -1 && errno == EBUSY) + ; if (fd > 2) (void) close(fd); return (0);