summaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorÁkos Kőrösi <korakos99@gmail.com>2026-05-18 18:21:06 +0200
committerÁkos Kőrösi <korakos99@gmail.com>2026-05-18 18:21:06 +0200
commit5e02368fe8042626bf740ff52980651146b608a4 (patch)
treedba8f443faabf591a5d228120286966122897316 /exec.c
parentca675175742174d6bfcd0263583f840e250fc58f (diff)
make it work again
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c16
1 files changed, 10 insertions, 6 deletions
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;
}