… | |
… | |
172 | |
172 | |
173 | if (!strcmp (tok, "END")) |
173 | if (!strcmp (tok, "END")) |
174 | break; |
174 | break; |
175 | else if (!strcmp (tok, "ENV") && recv (tok)) |
175 | else if (!strcmp (tok, "ENV") && recv (tok)) |
176 | envv->push_back (strdup (tok)); |
176 | envv->push_back (strdup (tok)); |
177 | else if (!strcmp (tok, "CWD") && recv (tok)) |
|
|
178 | { |
|
|
179 | if (chdir (tok)) |
|
|
180 | { |
|
|
181 | delete envv; |
|
|
182 | delete argv; |
|
|
183 | return err ("unable to change to working directory to '%s', aborting: %s.\n", |
|
|
184 | (char *)tok, strerror (errno)); |
|
|
185 | } |
|
|
186 | } |
|
|
187 | else if (!strcmp (tok, "ARG") && recv (tok)) |
177 | else if (!strcmp (tok, "ARG") && recv (tok)) |
188 | argv->push_back (strdup (tok)); |
178 | argv->push_back (strdup (tok)); |
189 | else |
179 | else |
190 | return err ("protocol error: unexpected NEW token.\n"); |
180 | return err ("protocol error: unexpected NEW token.\n"); |
191 | } |
181 | } |
… | |
… | |
209 | success = false; |
199 | success = false; |
210 | } |
200 | } |
211 | |
201 | |
212 | term->log_hook = 0; |
202 | term->log_hook = 0; |
213 | |
203 | |
214 | chdir ("/"); |
204 | chdir ("/"); // init might change to different working directory |
215 | |
205 | |
216 | if (!success) |
206 | if (!success) |
217 | term->destroy (); |
207 | term->destroy (); |
218 | |
208 | |
219 | send ("END"); send (success ? 1 : 0); |
209 | send ("END"); send (success ? 1 : 0); |