summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2016-10-26 15:38:44 +0200
committerDenys Vlasenko2016-10-26 15:38:44 +0200
commite19923f6652a638ac39c84012e97f52cf5a7568e (patch)
tree5557e71174d5e575d17df65c375593c67561eb17 /shell
parent647746076a24a50670a7fab38917606e0ac98be7 (diff)
downloadbusybox-e19923f6652a638ac39c84012e97f52cf5a7568e.zip
busybox-e19923f6652a638ac39c84012e97f52cf5a7568e.tar.gz
ash: [REDIR] Remove redundant CLOEXEC calls
Upstream commit: Date: Sun, 6 May 2007 19:28:56 +1000 [REDIR] Remove redundant CLOEXEC calls Now that we're marking file descriptors as CLOEXEC in savefd, we no longer need to close them on exec or in setinputfd. function old new delta ash_main 1478 1492 +14 setinputfile 224 226 +2 readtoken1 2752 2750 -2 shellexec 208 198 -10 clearredir 30 - -30 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 16/-42) Total: -26 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0490f7f..b404449 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5462,16 +5462,6 @@ popredir(int drop, int restore)
* Undo all redirections. Called on error or interrupt.
*/
-/*
- * Discard all saved file descriptors.
- */
-static void
-clearredir(int drop)
-{
- while (redirlist)
- popredir(drop, /*restore:*/ 0);
-}
-
static int
redirectsafe(union node *redir, int flags)
{
@@ -7559,7 +7549,6 @@ shellexec(char **argv, const char *path, int idx)
int exerrno;
int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
- clearredir(/*drop:*/ 1);
envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
if (strchr(argv[0], '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
@@ -10191,7 +10180,6 @@ closescript(void)
static void
setinputfd(int fd, int push)
{
- close_on_exec_on(fd);
if (push) {
pushfile();
g_parsefile->buf = NULL;
@@ -10223,6 +10211,8 @@ setinputfile(const char *fname, int flags)
}
if (fd < 10)
fd = savefd(fd);
+ else
+ close_on_exec_on(fd);
setinputfd(fd, flags & INPUT_PUSH_FILE);
out:
INT_ON;
@@ -13339,7 +13329,8 @@ reset(void)
tokpushback = 0;
checkkwd = 0;
/* from redir.c: */
- clearredir(/*drop:*/ 0);
+ while (redirlist)
+ popredir(/*drop:*/ 0, /*restore:*/ 0);
}
#if PROFILE