diff options
Diffstat (limited to 'exec.c')
| -rw-r--r-- | exec.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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; } |
