-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: iverniho <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/16 15:23:12 by Jskehan #+# #+# */ | ||
/* Updated: 2024/08/04 16:04:59 by iverniho ### ########.fr */ | ||
/* Updated: 2024/08/05 13:26:42 by iverniho ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -57,7 +57,7 @@ char *resolve_command_path(char *command, t_mini **mini) | |
i++; | ||
} | ||
ft_free_2d_array(&paths); | ||
g_mini->exit_status = 127; | ||
// g_mini->exit_status = 127; | ||
// printf("Command path not found for: %s\n", command); // Debug print | ||
return (NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: iverniho <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/16 10:52:13 by Jskehan #+# #+# */ | ||
/* Updated: 2024/08/05 11:49:49 by iverniho ### ########.fr */ | ||
/* Updated: 2024/08/05 16:12:13 by iverniho ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -26,6 +26,12 @@ static void child_redir(t_cmd *cmd) | |
perror("dup2"); | ||
close(cmd->fd_out); | ||
} | ||
if (cmd->fd_out == -1) | ||
{ | ||
// printf("fdout = -1\n"); | ||
if (close(STDOUT_FILENO) == -1) | ||
perror("close"); | ||
} | ||
} | ||
|
||
static void execute_command(t_mini *mini, t_cmd *cmd) | ||
|
@@ -49,7 +55,8 @@ static void execute_command(t_mini *mini, t_cmd *cmd) | |
} | ||
else | ||
{ | ||
mini_perror(CMD_NOT_FOUND, cmd->full_command[0], 127); | ||
// mini_perror(CMD_NOT_FOUND, cmd->full_command[0], 127); | ||
ft_error1(4, cmd->full_command[0], 127, cmd->full_command[0]); | ||
exit(127); | ||
} | ||
} | ||
|
@@ -118,16 +125,21 @@ static void wait_for_children(int num_cmds, t_mini *mini) | |
{ | ||
int status; | ||
|
||
(void)mini; | ||
for (int k = 0; k < num_cmds; k++) | ||
{ | ||
wait(&status); | ||
if (WIFEXITED(status)) | ||
{ | ||
mini->exit_status = WEXITSTATUS(status); | ||
// mini->exit_status = WEXITSTATUS(status); | ||
g_mini->exit_status = WEXITSTATUS(status); | ||
} | ||
else if (WIFSIGNALED(status)) | ||
{ | ||
mini->exit_status = 128 + WTERMSIG(status); | ||
// mini->exit_status = 128 + WTERMSIG(status); | ||
// g_mini->exit_status = 128 + WTERMSIG(status); | ||
g_mini->exit_status = 1; | ||
|
||
} | ||
} | ||
} | ||
|
@@ -180,11 +192,11 @@ void *check_to_fork(t_mini *mini, t_list *commands) | |
if (cmd->full_command && (dir = opendir(cmd->full_command[0])) != NULL) | ||
{ | ||
closedir(dir); | ||
mini->exit_status = 126; // Command is a directory | ||
g_mini->exit_status = 126; // Command is a directory | ||
return (NULL); | ||
} | ||
if (!cmd->full_command && cmd->is_heredoc == 1) | ||
return (mini->exit_status = 127, NULL);// Command not found | ||
return (g_mini->exit_status = 127, NULL);// Command not found | ||
cmd->command_path = resolve_command_path(cmd->full_command[0], &mini); | ||
if (cmd->command_path && access(cmd->command_path, X_OK) == 0) | ||
exec_pipes(mini, commands); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: iverniho <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/07 17:38:35 by iverniho #+# #+# */ | ||
/* Updated: 2024/08/05 12:53:42 by iverniho ### ########.fr */ | ||
/* Updated: 2024/08/05 16:32:33 by iverniho ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -185,10 +185,7 @@ void ft_error1(int error, char *arg, int exit_code, char *message) | |
else if (error == 9) | ||
{ | ||
ft_putstr_fd("minishell> export: ", STDERR_FILENO); | ||
|
||
ft_putendl_fd(ft_strjoin(add_quotes(arg), message), 2); | ||
// ft_putstr_fd("minishell> ", STDERR_FILENO); | ||
// ft_putendl_fd(message, 2); | ||
g_mini->exit_status = exit_code; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters