Skip to content
Myr

main: handle multi-argument 'paths' when executing application

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 4defe51 · Browse files · 1 file+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−2 removed

  • other:+24 added−2 removed

1 file+24 added−2 removed

modified:main.c+24 added-2 removed
448 unmodified lines
449 LOG_ERRNO("failed to fork");450451 if (pid == 0) {452 /* Child */453 execlp(c->matches[c->selected].application->path,454 c->matches[c->selected].application->path, NULL);453454 char *copy = strdup(c->matches[c->selected].application->path);455 char *argv[100];456457 size_t cnt = 0;458 for (char *arg = strtok(copy, " ");459 arg != NULL;460 arg = strtok(NULL, " "))461 {462 /* TODO: implement %-expansion */463 if (arg[0] == '%')464 continue;465466 argv[cnt++] = arg;467 }468469 close(STDIN_FILENO);470 close(STDOUT_FILENO);471 close(STDERR_FILENO);472473 argv[cnt] = NULL;474 execvp(argv[0], argv);475476 exit(1);477 } else {478 /* Parent */479 c->keep_running = false;480 }
591 unmodified lines