diff options
author | jilles <jilles@FreeBSD.org> | 2013-11-24 23:12:13 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-11-24 23:12:13 +0000 |
commit | 4e34b845870b14e6d758cd141e7c08f5225ae940 (patch) | |
tree | d5945aceac4152d0ab7de9eb45d68e0e9865344f /bin/sh | |
parent | 8fd329b496dfdd93de92d292f616b93bca9116e7 (diff) | |
download | FreeBSD-src-4e34b845870b14e6d758cd141e7c08f5225ae940.zip FreeBSD-src-4e34b845870b14e6d758cd141e7c08f5225ae940.tar.gz |
sh: Make <&0 disable the </dev/null implicit in a background command.
Although <&0 does nothing, it is a redirection affecting standard input and
should therefore disable the </dev/null redirection implicit in a background
command.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/redir.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/sh/redir.c b/bin/sh/redir.c index 9325545..79728a0 100644 --- a/bin/sh/redir.c +++ b/bin/sh/redir.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); struct redirtab { struct redirtab *next; int renamed[10]; + int fd0_redirected; }; @@ -109,11 +110,14 @@ redirect(union node *redir, int flags) sv = ckmalloc(sizeof (struct redirtab)); for (i = 0 ; i < 10 ; i++) sv->renamed[i] = EMPTY; + sv->fd0_redirected = fd0_redirected; sv->next = redirlist; redirlist = sv; } for (n = redir ; n ; n = n->nfile.next) { fd = n->nfile.fd; + if (fd == 0) + fd0_redirected = 1; if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) && n->ndup.dupfd == fd) continue; /* redirect from/to same file descriptor */ @@ -134,8 +138,6 @@ redirect(union node *redir, int flags) sv->renamed[fd] = i; INTON; } - if (fd == 0) - fd0_redirected++; openredirect(n, memory); } if (memory[1]) @@ -303,8 +305,6 @@ popredir(void) for (i = 0 ; i < 10 ; i++) { if (rp->renamed[i] != EMPTY) { - if (i == 0) - fd0_redirected--; if (rp->renamed[i] >= 0) { dup2(rp->renamed[i], i); close(rp->renamed[i]); @@ -314,6 +314,7 @@ popredir(void) } } INTOFF; + fd0_redirected = rp->fd0_redirected; redirlist = rp->next; ckfree(rp); INTON; |