From 5e02368fe8042626bf740ff52980651146b608a4 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Mon, 18 May 2026 18:21:06 +0200 Subject: make it work again --- exec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index d683099..e58a89b 100644 --- a/exec.c +++ b/exec.c @@ -13,6 +13,7 @@ void execute_command(Command cmd, int* pgid) { + pid_t pid = fork(); if (pid == 0) { @@ -52,18 +53,20 @@ void execute_command(Command cmd, int* pgid) { } } -Command make_command(SlotVec cmd_slots) { +Command make_command(ExpandedPipelineElement elem) { Command cmd = { .child_close_fds = make_IntVec(64), .parent_close_fds = make_IntVec(64), - .redirs = make_FdRedirectVec(32) + .redirs = make_FdRedirectVec(32), + .term = elem.conn, }; StrVec arg_strs = make_StrVec(256); - for (int i = 0; i < cmd_slots.count; i++) { - Slot slot = *get_from_SlotVec(&cmd_slots, i); + for (int i = 0; i < elem.cmd_slots.count; i++) { + Slot slot = *get_from_SlotVec(&elem.cmd_slots, i); switch (slot.kind) { case SLOT_STR: push_to_StrVec(&arg_strs, slot.as.str); + break; default: exit(67); // TODO: other slot kinds @@ -94,7 +97,7 @@ void run_cmds(CommandVec cmds) { } cmd.stdout_fd = STDOUT_FILENO; - if (cmd.term = CONN_PIPE) { + if (cmd.term == CONN_PIPE) { int pipe_fds[2]; pipe(pipe_fds); cmd.stdout_fd = pipe_fds[1]; @@ -120,9 +123,10 @@ CommandVec make_cmd_vec_pl(ExpandedPipeline pl) { CommandVec cmds = make_CommandVec(256); for (int i = 0; i < pl.count; i++) { ExpandedPipelineElement elem = *get_from_ExpandedPipeline(&pl, i); - Command cmd = make_command(elem.cmd_slots); + Command cmd = make_command(elem); push_to_CommandVec(&cmds, cmd); } + return cmds; } -- cgit v1.2.3