diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-28 16:43:18 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-28 16:43:18 +0000 |
commit | 18e19f2b0d36c0d9566d871942dfe282e9cf5a28 (patch) | |
tree | 22d3da65f1031bac1833c4f53c24b4f7876d5d6b /libbb | |
parent | a6a1785a30d6fe011eeabec3c19e154dc475b1b0 (diff) | |
download | busybox-w32-18e19f2b0d36c0d9566d871942dfe282e9cf5a28.tar.gz busybox-w32-18e19f2b0d36c0d9566d871942dfe282e9cf5a28.tar.bz2 busybox-w32-18e19f2b0d36c0d9566d871942dfe282e9cf5a28.zip |
hush: fix nofork + ctrl-Z clobbering of globals
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 78f3c4ad4..aef74e994 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -100,15 +100,28 @@ int wait_pid(int *wstat, int pid) | |||
100 | return r; | 100 | return r; |
101 | } | 101 | } |
102 | 102 | ||
103 | int run_nofork_applet(const struct bb_applet *a, char **argv) | 103 | void save_nofork_data(struct nofork_save_area *save) |
104 | { | 104 | { |
105 | int rc, argc; | 105 | save->current_applet = current_applet; |
106 | save->xfunc_error_retval = xfunc_error_retval; | ||
107 | save->option_mask32 = option_mask32; | ||
108 | save->die_sleep = die_sleep; | ||
109 | save->saved = 1; | ||
110 | } | ||
106 | 111 | ||
107 | /* Save some shared globals */ | 112 | void restore_nofork_data(struct nofork_save_area *save) |
108 | const struct bb_applet *old_a = current_applet; | 113 | { |
109 | int old_x = xfunc_error_retval; | 114 | current_applet = save->current_applet; |
110 | uint32_t old_m = option_mask32; | 115 | xfunc_error_retval = save->xfunc_error_retval; |
111 | int old_sleep = die_sleep; | 116 | option_mask32 = save->option_mask32; |
117 | die_sleep = save->die_sleep; | ||
118 | |||
119 | applet_name = current_applet->name; | ||
120 | } | ||
121 | |||
122 | int run_nofork_applet_prime(struct nofork_save_area *old, const struct bb_applet *a, char **argv) | ||
123 | { | ||
124 | int rc, argc; | ||
112 | 125 | ||
113 | current_applet = a; | 126 | current_applet = a; |
114 | applet_name = a->name; | 127 | applet_name = a->name; |
@@ -138,14 +151,18 @@ int run_nofork_applet(const struct bb_applet *a, char **argv) | |||
138 | } | 151 | } |
139 | 152 | ||
140 | /* Restoring globals */ | 153 | /* Restoring globals */ |
141 | current_applet = old_a; | 154 | restore_nofork_data(old); |
142 | applet_name = old_a->name; | ||
143 | xfunc_error_retval = old_x; | ||
144 | option_mask32 = old_m; | ||
145 | die_sleep = old_sleep; | ||
146 | return rc; | 155 | return rc; |
147 | } | 156 | } |
148 | 157 | ||
158 | int run_nofork_applet(const struct bb_applet *a, char **argv) | ||
159 | { | ||
160 | struct nofork_save_area old; | ||
161 | /* Saving globals */ | ||
162 | save_nofork_data(&old); | ||
163 | return run_nofork_applet_prime(&old, a, argv); | ||
164 | } | ||
165 | |||
149 | int spawn_and_wait(char **argv) | 166 | int spawn_and_wait(char **argv) |
150 | { | 167 | { |
151 | int rc; | 168 | int rc; |