aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/appletlib.c14
-rw-r--r--shell/ash.c7
3 files changed, 16 insertions, 6 deletions
diff --git a/include/libbb.h b/include/libbb.h
index af234e7b0..da3459224 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2075,6 +2075,7 @@ extern const char bb_path_wtmp_file[] ALIGN1;
2075#define bb_dev_null "/dev/null" 2075#define bb_dev_null "/dev/null"
2076#if ENABLE_PLATFORM_MINGW32 2076#if ENABLE_PLATFORM_MINGW32
2077#define bb_busybox_exec_path get_busybox_exec_path() 2077#define bb_busybox_exec_path get_busybox_exec_path()
2078extern char *bb_applet_pid(void);
2078#else 2079#else
2079extern const char bb_busybox_exec_path[] ALIGN1; 2080extern const char bb_busybox_exec_path[] ALIGN1;
2080#endif 2081#endif
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);
diff --git a/shell/ash.c b/shell/ash.c
index 6d24fb55a..2a1ddac39 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14975,6 +14975,13 @@ reinitvar(void)
14975 varinit[i].var_func = varinit_data[i].var_func; 14975 varinit[i].var_func = varinit_data[i].var_func;
14976 } 14976 }
14977 vlineno.var_text = linenovar; 14977 vlineno.var_text = linenovar;
14978
14979 /*
14980 * BB_APPLET_<pid> was correct when 'sh --forkshell' was started
14981 * but has now been overwritten by the environment from the forkshell
14982 * data block. Reinstate it.
14983 */
14984 setvareq(bb_applet_pid(), VEXPORT);
14978} 14985}
14979 14986
14980/* FIXME: should consider running forkparent() and forkchild() */ 14987/* FIXME: should consider running forkparent() and forkchild() */