Minishell 1.0
42 School Minishell Project - A simple shell implementation
Yüklüyor...
Arıyor...
Eşleşme Yok
executor_pipe_utils.c
Bu dosyanın dokümantasyonuna git.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* executor_pipe_utils.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: hgenc <hgenc@student.42kocaeli.com.tr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/02/16 18:10:00 by hgenc #+# #+# */
9/* Updated: 2026/02/16 18:10:00 by hgenc ### ########.fr */
10/* */
11/* ************************************************************************** */
12
14#include <unistd.h>
15
16/**
17 * @brief Pipe'ın sol tarafını çalıştır
18 */
19void pipe_left_child(t_shell *shell, t_ast *node, int *pipefd)
20{
21 int exit_status;
22
24 close(pipefd[0]);
25 dup2(pipefd[1], STDOUT_FILENO);
26 close(pipefd[1]);
27 exit_status = execute_ast(shell, node->left);
28 shell_exit(shell, exit_status);
29}
30
31/**
32 * @brief Pipe'ın sağ tarafını çalıştır
33 */
34void pipe_right_child(t_shell *shell, t_ast *node, int *pipefd)
35{
36 int exit_status;
37
39 close(pipefd[1]);
40 dup2(pipefd[0], STDIN_FILENO);
41 close(pipefd[0]);
42 exit_status = execute_ast(shell, node->right);
43 shell_exit(shell, exit_status);
44}
45
46/**
47 * @brief İki child'ı bekle, sağ tarafın exit status'unu döndür
48 */
49int wait_pipe(pid_t left_pid, pid_t right_pid)
50{
51 int result;
52
53 wait_for_child(left_pid);
54 result = wait_for_child(right_pid);
55 if (result == 130)
56 write(1, "\n", 1);
57 return (result);
58}
void shell_exit(t_shell *shell, int exit_code)
Shell'i temizleyip programdan çıkar.
Definition cleanup.c:76
int execute_ast(t_shell *shell, t_ast *node)
AST node'unu tipine göre çalıştır.
Definition executor.c:26
void pipe_left_child(t_shell *shell, t_ast *node, int *pipefd)
Pipe'ın sol tarafını çalıştır.
int wait_pipe(pid_t left_pid, pid_t right_pid)
İki child'ı bekle, sağ tarafın exit status'unu döndür.
void pipe_right_child(t_shell *shell, t_ast *node, int *pipefd)
Pipe'ın sağ tarafını çalıştır.
int wait_for_child(pid_t pid)
Child process'i bekle ve exit status al EINTR: sinyal gelirse waitpid'i tekrar dene (zombie bırakma).
Minishell ana header dosyası
struct s_ast t_ast
struct s_shell t_shell
void reset_signals(void)
Definition signals.c:73
struct s_ast * right
Definition minishell.h:144
struct s_ast * left
Definition minishell.h:143