aboutsummaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-04 21:54:22 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-04 21:54:22 +0000
commit174420d2bc39c611fbc09669490b96fc6cc81520 (patch)
treeba3e9d43d0551624590a010db8a6282e2cfbebc2 /login
parentb80bfc8b53153ca9aefa32ecd51ac4d6cfdbb842 (diff)
downloadglibc-174420d2bc39c611fbc09669490b96fc6cc81520.zip
glibc-174420d2bc39c611fbc09669490b96fc6cc81520.tar.gz
glibc-174420d2bc39c611fbc09669490b96fc6cc81520.tar.bz2
* 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.
Diffstat (limited to 'login')
-rw-r--r--login/login_tty.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/login/login_tty.c b/login/login_tty.c
index 1bb1703..2ba276d 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 <errno.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -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);