Skip to content

Commit 7c3de5e

Browse files
committed
fix(dispatcher): pip shim in swap context uses -m pip instead of direct execv
1 parent f8ab8d7 commit 7c3de5e

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/omnipkg/dispatcher.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,22 @@ int main(int argc, char **argv) {
12641264
registry_lookup(_swap_venv, swap_ver, swap_py, sizeof(swap_py));
12651265
if (swap_py[0] && file_exists(swap_py)) {
12661266
if (debug) fprintf(stderr, "[C-DISPATCH] swap shim → execv %s\n", swap_py);
1267-
argv[0] = swap_py;
1268-
execv(swap_py, argv);
1267+
if (strcmp(prog, "pip") == 0) {
1268+
/* pip: execv python -m pip <args> */
1269+
int argc = 0;
1270+
while (argv[argc]) argc++;
1271+
char **new_argv = malloc((argc + 3) * sizeof(char *));
1272+
new_argv[0] = swap_py;
1273+
new_argv[1] = "-m";
1274+
new_argv[2] = "pip";
1275+
for (int i = 1; i < argc; i++)
1276+
new_argv[i + 2] = argv[i];
1277+
new_argv[argc + 2] = NULL;
1278+
execv(swap_py, new_argv);
1279+
} else {
1280+
argv[0] = swap_py;
1281+
execv(swap_py, argv);
1282+
}
12691283
perror("omnipkg: execv swap python failed");
12701284
exit(1);
12711285
}

0 commit comments

Comments
 (0)