Minishell 1.0
42 School Minishell Project - A simple shell implementation
Yüklüyor...
Arıyor...
Eşleşme Yok
executor.c
Bu dosyanın dokümantasyonuna git.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* executor.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: hgenc <hgenc@student.42kocaeli.com.tr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/01/26 00:00:00 by hgenc #+# #+# */
9/* Updated: 2026/02/03 16:21:00 by hgenc ### ########.fr */
10/* */
11/* ************************************************************************** */
12
14#include <stdlib.h>
15#include <sys/wait.h>
16#include <unistd.h>
17
18
19
20/**
21 * @brief AST node'unu tipine göre çalıştır
22 * @param shell Shell structure
23 * @param node AST node
24 * @return int exit status
25 */
26int execute_ast(t_shell *shell, t_ast *node)
27{
28 int result;
29
30 if (!node)
31 return (0);
32 if (node->type == NODE_CMD)
33 result = execute_cmd(shell, node->cmd);
34 else if (node->type == NODE_PIPE)
35 result = execute_pipe(shell, node);
36 else if (node->type == NODE_SEQ)
37 {
38 execute_ast(shell, node->left);
39 result = execute_ast(shell, node->right);
40 }
41 else
42 result = 0;
43 shell->exit_status = result;
44 return (result);
45}
46
47/**
48 * @brief Ana executor entry point
49 * @param shell Shell structure
50 * @return int exit status
51 */
52int executor(t_shell *shell)
53{
54 int status;
55
56 if (!shell || !shell->ast_root)
57 return (0);
58 status = execute_ast(shell, shell->ast_root);
59 return (status);
60}
int executor(t_shell *shell)
Ana executor entry point.
Definition executor.c:52
int execute_ast(t_shell *shell, t_ast *node)
AST node'unu tipine göre çalıştır.
Definition executor.c:26
int execute_cmd(t_shell *shell, t_cmd *cmd)
Ana komut çalıştırma dispatcher.
int execute_pipe(t_shell *shell, t_ast *node)
Pipe node'unu çalıştır Her iki taraf da child process'te çalışır.
Minishell ana header dosyası
struct s_ast t_ast
@ NODE_CMD
Definition minishell.h:136
@ NODE_PIPE
Definition minishell.h:135
@ NODE_SEQ
Definition minishell.h:137
struct s_shell t_shell
t_node_type type
Definition minishell.h:141
struct s_ast * right
Definition minishell.h:144
struct s_ast * left
Definition minishell.h:143
t_cmd * cmd
Definition minishell.h:142
t_ast * ast_root
Definition minishell.h:150
int exit_status
Definition minishell.h:153