summaryrefslogtreecommitdiffstats
path: root/bin/sh/main.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-06-13 21:17:45 +0000
committerjilles <jilles@FreeBSD.org>2009-06-13 21:17:45 +0000
commit884d344808b868ba1813aabf798a590a5a99683a (patch)
tree1ba6a6bdd17a2f3f559156b067a6e4ca4fb08707 /bin/sh/main.c
parent7decb9c312312e3869ccb7439115644dc95ed665 (diff)
downloadFreeBSD-src-884d344808b868ba1813aabf798a590a5a99683a.zip
FreeBSD-src-884d344808b868ba1813aabf798a590a5a99683a.tar.gz
Avoid leaving unnecessary waiting shells in many forms of sh -c COMMAND.
This change only affects strings passed to -c, when the -s option is not used. The approach is to check if there may be additional data in the string after parsing each command. If there is none, use the EV_EXIT flag so that a fork may be omitted in specific cases. If there are empty lines after the command, the check will not see the end and forks will not be omitted. The same thing seems to happen in bash. Example: sh -c 'ps lT' No longer shows a shell process waiting for ps to finish. PR: bin/113860 Reviewed by: stefanf Approved by: ed (mentor)
Diffstat (limited to 'bin/sh/main.c')
-rw-r--r--bin/sh/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c
index 77526b5..85a6d20 100644
--- a/bin/sh/main.c
+++ b/bin/sh/main.c
@@ -178,7 +178,7 @@ state2:
state3:
state = 4;
if (minusc) {
- evalstring(minusc, 0);
+ evalstring(minusc, sflag ? 0 : EV_EXIT);
}
if (sflag || minusc == NULL) {
state4: /* XXX ??? - why isn't this before the "if" statement */
OpenPOWER on IntegriCloud