Skip to content

Commit 16c8b64

Browse files
committed
wslbridge.exe must be located in the /wsl subdir; bypass 'ConEmuBaseDir' env.var to linux side
1 parent a3e27d5 commit 16c8b64

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

ConEmuT.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,21 +1419,33 @@ int main(int argc, char** argv)
14191419
char** buf_argv = NULL;
14201420
if (wsl_bridge)
14211421
{
1422-
int child_cnt = 1; // the "/.../.../wslbridge.exe" and it's arguments from cur_argv?
1422+
// the "/.../.../wslbridge.exe" + "-eConEmuBaseDir" and it's arguments from cur_argv?
1423+
int child_cnt = 2;
14231424
for (int i = 0; cur_argv[i]; ++i, ++child_cnt);
1425+
// allocate +1 more item for terminating NULL
14241426
buf_argv = (char**)calloc(child_cnt+1, sizeof(char*));
1425-
for (int i = 0; cur_argv[i]; ++i, ++child_cnt)
1426-
buf_argv[i+1] = cur_argv[i];
1427-
// The tail is ready, not the path for wslbridge.exe
1428-
// we expect it must be in the same dir where our connector's exe is located
1429-
const char wslbridge_exe[] = "wslbridge.exe";
1427+
1428+
// We expect the wslbridge.exe must be located in the
1429+
// "/wsl" subdir of the dir with our connector's exe
1430+
const char wslbridge_exe[] = "wsl/wslbridge.exe";
14301431
int max_len = strlen(argv[0]) + strlen(wslbridge_exe);
1431-
buf_argv[0] = (char*)malloc(max_len*sizeof(buf_argv[0][0]));
1432-
strcpy(buf_argv[0], argv[0]);
1433-
char* slash = strrchr(buf_argv[0], '/');
1434-
if (slash) ++slash; else slash = buf_argv[0];
1435-
strcpy(slash, wslbridge_exe);
1436-
child_argv = buf_argv;
1432+
buf_argv[0] = (char*)malloc(max_len*sizeof(**buf_argv));
1433+
strcpy(buf_argv[0], argv[0]);
1434+
char* slash = strrchr(buf_argv[0], '/');
1435+
if (slash) ++slash; else slash = buf_argv[0];
1436+
strcpy(slash, wslbridge_exe);
1437+
1438+
// Bypass to linux side env.var "ConEmuBaseDir" (JFI)
1439+
const char env_var[] = "-eConEmuBaseDir";
1440+
buf_argv[1] = (char*)malloc((strlen(env_var)+1)*sizeof(**buf_argv));
1441+
strcpy(buf_argv[1], env_var);
1442+
1443+
// Prepare the tail, if exists
1444+
for (int i = 0; cur_argv[i]; ++i, ++child_cnt)
1445+
buf_argv[i+2] = cur_argv[i];
1446+
1447+
// All done, arguments are ready
1448+
child_argv = buf_argv;
14371449
}
14381450

14391451
#if defined(SHOW_CHILD_ERR_MSG)

0 commit comments

Comments
 (0)