summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-01-08 08:56:43 +0000
committerRon Yorston <rmy@pobox.com>2017-01-08 08:56:43 +0000
commit3ef86d069577b8a44ebe3aa890c6e97ea31d0d56 (patch)
tree064587c9b2080dba963bf8d93861b8019cb306ed /shell/ash.c
parentc66975af0b5335b9cdd156206767756237bd814b (diff)
parent86584e134eec1a81298149f8c04c77727f6dccb9 (diff)
downloadbusybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.tar.gz
busybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.tar.bz2
busybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 35618937a..fe185f5d9 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -41,6 +41,11 @@
41//config: shell (by Herbert Xu), which was created by porting the 'ash' shell 41//config: shell (by Herbert Xu), which was created by porting the 'ash' shell
42//config: (written by Kenneth Almquist) from NetBSD. 42//config: (written by Kenneth Almquist) from NetBSD.
43//config: 43//config:
44//config:# ash options
45//config:# note: Don't remove !NOMMU part in the next line; it would break
46//config:# menuconfig's indenting.
47//config:if !NOMMU && (ASH || SH_IS_ASH || BASH_IS_ASH)
48//config:
44//config:config ASH_OPTIMIZE_FOR_SIZE 49//config:config ASH_OPTIMIZE_FOR_SIZE
45//config: bool "Optimize for size instead of speed" 50//config: bool "Optimize for size instead of speed"
46//config: default y 51//config: default y
@@ -155,6 +160,8 @@
155//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH 160//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
156//config: help 161//config: help
157//config: Enable "check for new mail" function in the ash shell. 162//config: Enable "check for new mail" function in the ash shell.
163//config:
164//config:endif # ash options
158 165
159//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) 166//applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
160//applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) 167//applet:IF_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, ash))
@@ -5778,11 +5785,11 @@ redirect(union node *redir, int flags)
5778 /* Careful to not accidentally "save" 5785 /* Careful to not accidentally "save"
5779 * to the same fd as right side fd in N>&M */ 5786 * to the same fd as right side fd in N>&M */
5780 int minfd = right_fd < 10 ? 10 : right_fd + 1; 5787 int minfd = right_fd < 10 ? 10 : right_fd + 1;
5788#if defined(F_DUPFD_CLOEXEC)
5789 i = fcntl(fd, F_DUPFD_CLOEXEC, minfd);
5790#else
5781 i = fcntl(fd, F_DUPFD, minfd); 5791 i = fcntl(fd, F_DUPFD, minfd);
5782/* You'd expect copy to be CLOEXECed. Currently these extra "saved" fds 5792#endif
5783 * are closed in popredir() in the child, preventing them from leaking
5784 * into child. (popredir() also cleans up the mess in case of failures)
5785 */
5786 if (i == -1) { 5793 if (i == -1) {
5787 i = errno; 5794 i = errno;
5788 if (i != EBADF) { 5795 if (i != EBADF) {
@@ -5797,6 +5804,9 @@ redirect(union node *redir, int flags)
5797 remember_to_close: 5804 remember_to_close:
5798 i = CLOSED; 5805 i = CLOSED;
5799 } else { /* fd is open, save its copy */ 5806 } else { /* fd is open, save its copy */
5807#if !defined(F_DUPFD_CLOEXEC)
5808 fcntl(i, F_SETFD, FD_CLOEXEC);
5809#endif
5800 /* "exec fd>&-" should not close fds 5810 /* "exec fd>&-" should not close fds
5801 * which point to script file(s). 5811 * which point to script file(s).
5802 * Force them to be restored afterwards */ 5812 * Force them to be restored afterwards */