open_pipes() bugfix
+ write "exit" to STDERR (like bash) + set_last_exit_status() on CTRL-C
This commit is contained in:
@@ -45,7 +45,7 @@ static int open_pipes(t_cmd *pipeline[])
|
||||
else
|
||||
if (close(pipes[STDOUT_FILENO]) == -1)
|
||||
perror("close()");
|
||||
if (pipeline[i]->fd_in == STDIN_FILENO)
|
||||
if (pipeline[i + 1]->fd_in == STDIN_FILENO)
|
||||
pipeline[i + 1]->fd_in = pipes[STDIN_FILENO];
|
||||
else
|
||||
if (close(pipes[STDIN_FILENO]) == -1)
|
||||
|
||||
@@ -53,7 +53,7 @@ static char *read_input(char *prompt, t_all *c)
|
||||
sigaction(SIGINT, &signal_behaviour, NULL);
|
||||
if (!line_input)
|
||||
{
|
||||
write(1, "exit\n", 5);
|
||||
write(STDERR_FILENO, "exit\n", 5);
|
||||
exit_free(c, get_last_exit_status());
|
||||
}
|
||||
return (line_input);
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
void sigint_handler_interactive(int signum)
|
||||
{
|
||||
(void)signum;
|
||||
write(1, "\n", 1);
|
||||
rl_on_new_line();
|
||||
rl_replace_line("", 1);
|
||||
rl_redisplay();
|
||||
set_last_exit_status(EXIT_SIGNAL + signum);
|
||||
}
|
||||
|
||||
void sigint_handler_heredoc(int signum)
|
||||
|
||||
Reference in New Issue
Block a user