@@ -94,6 +94,7 @@ struct ForkLaunchInfo {
94
94
bool debug;
95
95
bool disable_aslr;
96
96
std::string wd;
97
+ std::string executable;
97
98
const char **argv;
98
99
Environment::Envp envp;
99
100
std::vector<ForkFileAction> actions;
@@ -194,7 +195,8 @@ struct ForkLaunchInfo {
194
195
}
195
196
196
197
// Execute. We should never return...
197
- execve (info.argv [0 ], const_cast <char *const *>(info.argv ), info.envp );
198
+ execve (info.executable .c_str (), const_cast <char *const *>(info.argv ),
199
+ info.envp );
198
200
199
201
#if defined(__linux__)
200
202
if (errno == ETXTBSY) {
@@ -207,7 +209,8 @@ struct ForkLaunchInfo {
207
209
// Since this state should clear up quickly, wait a while and then give it
208
210
// one more go.
209
211
usleep (50000 );
210
- execve (info.argv [0 ], const_cast <char *const *>(info.argv ), info.envp );
212
+ execve (info.executable .c_str (), const_cast <char *const *>(info.argv ),
213
+ info.envp );
211
214
}
212
215
#endif
213
216
@@ -236,8 +239,17 @@ ForkLaunchInfo::ForkLaunchInfo(const ProcessLaunchInfo &info)
236
239
debug(info.GetFlags().Test(eLaunchFlagDebug)),
237
240
disable_aslr(info.GetFlags().Test(eLaunchFlagDisableASLR)),
238
241
wd(info.GetWorkingDirectory().GetPath()),
242
+ executable(info.GetExecutableFile().GetPath()),
239
243
argv(info.GetArguments().GetConstArgumentVector()),
240
- envp(info.GetEnvironment().getEnvp()), actions(MakeForkActions(info)) {}
244
+ envp(info.GetEnvironment().getEnvp()), actions(MakeForkActions(info)) {
245
+ // If we didn't get an executable, use args vector to locate the executable
246
+ // instead
247
+ if (executable.empty ())
248
+ executable = argv[0 ];
249
+ // If it was requested to override arg 0 at exec, respect that
250
+ if (!info.GetArg0 ().empty ())
251
+ argv[0 ] = info.GetArg0 ().data ();
252
+ }
241
253
242
254
HostProcess
243
255
ProcessLauncherPosixFork::LaunchProcess (const ProcessLaunchInfo &launch_info,
0 commit comments