aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-26 15:38:44 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-26 15:38:44 +0200
commite19923f6652a638ac39c84012e97f52cf5a7568e (patch)
tree5557e71174d5e575d17df65c375593c67561eb17
parent647746076a24a50670a7fab38917606e0ac98be7 (diff)
downloadbusybox-w32-e19923f6652a638ac39c84012e97f52cf5a7568e.tar.gz
busybox-w32-e19923f6652a638ac39c84012e97f52cf5a7568e.tar.bz2
busybox-w32-e19923f6652a638ac39c84012e97f52cf5a7568e.zip
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>
-rw-r--r--shell/ash.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0490f7f7d..b404449d0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5462,16 +5462,6 @@ popredir(int drop, int restore)
5462 * Undo all redirections. Called on error or interrupt. 5462 * Undo all redirections. Called on error or interrupt.
5463 */ 5463 */
5464 5464
5465/*
5466 * Discard all saved file descriptors.
5467 */
5468static void
5469clearredir(int drop)
5470{
5471 while (redirlist)
5472 popredir(drop, /*restore:*/ 0);
5473}
5474
5475static int 5465static int
5476redirectsafe(union node *redir, int flags) 5466redirectsafe(union node *redir, int flags)
5477{ 5467{
@@ -7559,7 +7549,6 @@ shellexec(char **argv, const char *path, int idx)
7559 int exerrno; 7549 int exerrno;
7560 int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ 7550 int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
7561 7551
7562 clearredir(/*drop:*/ 1);
7563 envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); 7552 envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
7564 if (strchr(argv[0], '/') != NULL 7553 if (strchr(argv[0], '/') != NULL
7565#if ENABLE_FEATURE_SH_STANDALONE 7554#if ENABLE_FEATURE_SH_STANDALONE
@@ -10191,7 +10180,6 @@ closescript(void)
10191static void 10180static void
10192setinputfd(int fd, int push) 10181setinputfd(int fd, int push)
10193{ 10182{
10194 close_on_exec_on(fd);
10195 if (push) { 10183 if (push) {
10196 pushfile(); 10184 pushfile();
10197 g_parsefile->buf = NULL; 10185 g_parsefile->buf = NULL;
@@ -10223,6 +10211,8 @@ setinputfile(const char *fname, int flags)
10223 } 10211 }
10224 if (fd < 10) 10212 if (fd < 10)
10225 fd = savefd(fd); 10213 fd = savefd(fd);
10214 else
10215 close_on_exec_on(fd);
10226 setinputfd(fd, flags & INPUT_PUSH_FILE); 10216 setinputfd(fd, flags & INPUT_PUSH_FILE);
10227 out: 10217 out:
10228 INT_ON; 10218 INT_ON;
@@ -13339,7 +13329,8 @@ reset(void)
13339 tokpushback = 0; 13329 tokpushback = 0;
13340 checkkwd = 0; 13330 checkkwd = 0;
13341 /* from redir.c: */ 13331 /* from redir.c: */
13342 clearredir(/*drop:*/ 0); 13332 while (redirlist)
13333 popredir(/*drop:*/ 0, /*restore:*/ 0);
13343} 13334}
13344 13335
13345#if PROFILE 13336#if PROFILE