Permalink
Browse files

Don't error out if stderr is redirected.

If a process is run as $cmd 2>/dev/null, we can still find a terminal on fd's 0
and 1, so don't spuriously error out.
  • Loading branch information...
1 parent d69f9d2 commit 15ce48bdb852e0a29fa7d779ec9fe2773beb1c04 @nelhage committed Jul 21, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 attach.c
View
@@ -263,11 +263,11 @@ void wait_for_stop(pid_t pid, int fd) {
int copy_tty_state(pid_t pid, const char *pty) {
char buf[PATH_MAX];
- int fd, err = 0;
+ int fd, err = EINVAL;
struct termios tio;
int i;
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 3 && err; i++) {
err = 0;
snprintf(buf, sizeof buf, "/proc/%d/fd/%d", pid, i);

0 comments on commit 15ce48b

Please sign in to comment.