From de11428a45eb36dfa1c39fc59b56d0273fbec4a0 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Thu, 21 May 2026 09:51:42 +0200 Subject: got new flow working(?) --- redes/exec.c | 16 +++++++++++++--- redes/preproc.c | 8 ++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/redes/exec.c b/redes/exec.c index 964b0a0..8fb42b8 100644 --- a/redes/exec.c +++ b/redes/exec.c @@ -1,13 +1,17 @@ #include #include #include +#include +#include #include "syntax.h" void execute_cmd(ExecutableCommand cmd, int* pgid) { - printf("ok\n"); + printf("Ok\n"); + fflush(stdout); + pid_t pid = fork(); if (pid == 0) { @@ -100,9 +104,15 @@ void execute_command_pipeline(Pipeline pipeline) { int trunk_fd = STDIN_FILENO; int pgid = -1; - size_t i = 0; + printf("Starting pipeline of length %d\n", pipeline.count); + fflush(stdout); + + signal(SIGTTIN, SIG_IGN); + signal(SIGTTOU, SIG_IGN); for (int i = 0; i < pipeline.count; i++) { + printf("Processing cmd %d\n", i); + fflush(stdout); PlCommand cmd = *get_from_Pipeline(&pipeline, i); ExecutableCommand exec_cmd = process_pl_command(cmd); exec_cmd.stdin_fd = trunk_fd; @@ -130,7 +140,7 @@ void execute_command_pipeline(Pipeline pipeline) { } void execute_pipeline_tree(PipelineTree pltree) { - printf("Hello"); + printf("Hello\n"); fflush(stdout); execute_command_pipeline(*pltree.root); } diff --git a/redes/preproc.c b/redes/preproc.c index 1ba4640..33a00e4 100644 --- a/redes/preproc.c +++ b/redes/preproc.c @@ -56,16 +56,11 @@ Pipeline* process_token_sequence(TokenVec tokens, PipelineVec* pl_pool) { ); tok_pos++ ) { - printf("Tok pos: %d\n", tok_pos); StrVec exp_word; switch (curr_tok.kind) { case TOK_WORD: exp_word = process_word(curr_tok.as.word); - printf("hi %d\n", exp_word.count); - fflush(stdout); for (int j = 0; j < exp_word.count; j++) { - printf("%d\n", j); - fflush(stdout); char* arg_str = *get_from_StrVec(&exp_word, j); push_to_ArgVec(&pl_cmd.args, (Arg){.kind = ARG_LIT, .as.lit_str = arg_str}); } @@ -74,7 +69,7 @@ Pipeline* process_token_sequence(TokenVec tokens, PipelineVec* pl_pool) { exit(68); // TODO: the other kinds } } - Token delim_tok = *get_from_TokenVec(&tokens, tok_pos); + Token delim_tok = *get_from_TokenVec(&tokens, tok_pos++); assert(delim_tok.kind == TOK_SPEC); switch (delim_tok.as.spec) { case SPEC_PIPE: @@ -86,6 +81,7 @@ Pipeline* process_token_sequence(TokenVec tokens, PipelineVec* pl_pool) { default: exit(69); } + push_to_Pipeline(&pl, pl_cmd); } return push_to_PipelineVec(pl_pool, pl); } -- cgit v1.2.3