MiniDevil As beautiful as a shell
execute_utils.c File Reference

Execution output capture. More...

#include "minishell_ui.h"
#include "token.h"
#include "parser.h"
#include "ast.h"
#include "executor.h"
+ Include dependency graph for execute_utils.c:

Detailed Description

Execution output capture.

Definition in file execute_utils.c.

Functions

static void process_output_char (t_ui *ui, char c, char *line, int *line_len)
 Process 1 output character from the child pipe into line buffers. More...
 
void read_output_from_fd (t_ui *ui, int fd)
 Read all available bytes from fd and split into output lines. More...
 
int process_ui_input (char *input, t_shell *shell)
 Full pipeline inside the UI. More...
 

Function Documentation

◆ process_output_char()

static void process_output_char ( t_ui ui,
char  c,
char *  line,
int *  line_len 
)
static

Process 1 output character from the child pipe into line buffers.

  • On \n it flushes the current line to out_add_line() & resets len
  • Otherwise it appends c to line if below BUF_SIZE - 2
Parameters
uiUI state
cCharacter read from the pipe
lineWorking buffer (accumulates the current line)
line_lenPointer to the current position in the line

Definition at line 30 of file execute_utils.c.

References BUF_SIZE, t_ui::out, and out_add_line().

Referenced by read_output_from_fd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_output_from_fd()

void read_output_from_fd ( t_ui ui,
int  fd 
)

Read all available bytes from fd and split into output lines.

Reads in chunks of BUF_SIZE and any unterminated line is flushed after EOF

Parameters
uiUI states
fdFile descriptor to read from (pipe read end)

Definition at line 53 of file execute_utils.c.

References BUF_SIZE, t_ui::out, out_add_line(), and process_output_char().

Referenced by exec_parent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_ui_input()

int process_ui_input ( char *  input,
t_shell shell 
)

Full pipeline inside the UI.

tokenize -> expand_all_tokens -> parse -> collect_heredocs -> executor

Parameters
inputCommand string to execute
shellShell state (provides environment and execution context)
Returns
Exit status of the command, 1 on expand error, 2 on failure and 130 on heredoc interruption

Definition at line 88 of file execute_utils.c.

References collect_heredocs(), executor(), expand_all_tokens(), free_ast(), free_token_list(), parse(), and tokenize().

Referenced by exec_child().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Go to the source code of this file.