* 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.
This commit is contained in:
Ulrich Drepper 2007-10-04 21:54:22 +00:00
parent b80bfc8b53
commit 174420d2bc
2 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,9 @@
2007-10-04 Ulrich Drepper <drepper@redhat.com> 2007-10-04 Ulrich Drepper <drepper@redhat.com>
* 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 * misc/error.h: Remove support for use outside of libc. We have to
include <features.h> now. Include <bits/error.h> if possible. include <features.h> now. Include <bits/error.h> if possible.
* misc/bits/error.h: New file. * misc/bits/error.h: New file.

View File

@ -31,6 +31,7 @@
static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <errno.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <unistd.h> #include <unistd.h>
@ -63,9 +64,12 @@ login_tty(fd)
} }
} }
#endif #endif
(void) dup2(fd, 0); while (dup2(fd, 0) == -1 && errno == EBUSY)
(void) dup2(fd, 1); ;
(void) dup2(fd, 2); while (dup2(fd, 1) == -1 && errno == EBUSY)
;
while (dup2(fd, 2) == -1 && errno == EBUSY)
;
if (fd > 2) if (fd > 2)
(void) close(fd); (void) close(fd);
return (0); return (0);