aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-04-03 09:40:47 +0100
committerRon Yorston <rmy@pobox.com>2018-04-03 12:28:21 +0100
commited8eb229df581c702e44a352aaf4ed47b64bf623 (patch)
tree953df3a55d3c75b80f6e1553d5b8cfa38fffa614 /libbb
parentb7115d6ab736c0e9968bec3460ffa5cb12c94965 (diff)
downloadbusybox-w32-ed8eb229df581c702e44a352aaf4ed47b64bf623.tar.gz
busybox-w32-ed8eb229df581c702e44a352aaf4ed47b64bf623.tar.bz2
busybox-w32-ed8eb229df581c702e44a352aaf4ed47b64bf623.zip
ash: reinstate applet name variable after forkshell
When 'sh --forkshell' is invoked the BB_APPLET_<pid> environment variable is set, but then it's cleared when the environment of the child process is restored. Reinstate it in reinitvar.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 210f9ff4d..1488d4bd6 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -796,6 +796,13 @@ static void install_links(const char *busybox UNUSED_PARAM,
796 796
797static void run_applet_and_exit(const char *name, char **argv) NORETURN; 797static void run_applet_and_exit(const char *name, char **argv) NORETURN;
798 798
799#if ENABLE_PLATFORM_MINGW32
800char *bb_applet_pid(void)
801{
802 return auto_string(xasprintf("BB_APPLET_%d=%s", getpid(), applet_name));
803}
804#endif
805
799# if ENABLE_BUSYBOX 806# if ENABLE_BUSYBOX
800# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION 807# if ENABLE_FEATURE_SH_STANDALONE && ENABLE_FEATURE_TAB_COMPLETION
801 /* 808 /*
@@ -1008,12 +1015,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
1008 check_suid(applet_no); 1015 check_suid(applet_no);
1009 1016
1010#if ENABLE_PLATFORM_MINGW32 1017#if ENABLE_PLATFORM_MINGW32
1011 { 1018 putenv(bb_applet_pid());
1012 char var[64];
1013
1014 sprintf(var, "BB_APPLET_%d=%s", getpid(), applet_name);
1015 putenv(var);
1016 }
1017#endif 1019#endif
1018 1020
1019 xfunc_error_retval = applet_main[applet_no](argc, argv); 1021 xfunc_error_retval = applet_main[applet_no](argc, argv);