From 884d344808b868ba1813aabf798a590a5a99683a Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 13 Jun 2009 21:17:45 +0000 Subject: 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) --- bin/sh/eval.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin/sh/eval.h') diff --git a/bin/sh/eval.h b/bin/sh/eval.h index 11f7470..c82585e 100644 --- a/bin/sh/eval.h +++ b/bin/sh/eval.h @@ -45,6 +45,11 @@ struct backcmd { /* result of evalbackcmd */ struct job *jp; /* job structure for command */ }; +/* flags in argument to evaltree/evalstring */ +#define EV_EXIT 01 /* exit after evaluating tree */ +#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ +#define EV_BACKCMD 04 /* command executing within back quotes */ + int evalcmd(int, char **); void evalstring(char *, int); union node; /* BLETCH for ansi C */ -- cgit v1.1