shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=y

function                                             old     new   delta
re_execed_comm                                         -      46     +46
main                                                  72      86     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0)               Total: 60 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2021-10-11 18:39:25 +02:00
parent 23aba8a9a6
commit 5acf5e1f87
7 changed files with 78 additions and 2 deletions

View File

@@ -1112,8 +1112,14 @@ int main(int argc UNUSED_PARAM, char **argv)
|| ENABLE_FEATURE_PREFER_APPLETS
|| !BB_MMU
) {
if (NUM_APPLETS > 1)
set_task_comm(applet_name);
if (NUM_APPLETS > 1) {
/* Careful, do not trash comm of "SCRIPT.sh" -
* the case when started from e.g. #!/bin/ash script.
* (not limited to shells - #!/bin/awk scripts also exist)
*/
if (re_execed_comm())
set_task_comm(applet_name);
}
}
parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */