Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
ba1ba449
Commit
ba1ba449
authored
Jan 04, 2021
by
abenoit
Browse files
multipipes wait for child process finish crash
parent
6bef610c
Changes
2
Hide whitespace changes
Inline
Side-by-side
notes.txt
View file @
ba1ba449
...
...
@@ -12,6 +12,8 @@ export fd='$fs'
testlines pour multipipes :
cat | cat | ls
cat /dev/urandom | cat
ls -la | grep oct | tr -dc '0-9'
segfault quand on fait ctrl-d directement a la premiere commande de minishell
...
...
src/main.c
View file @
ba1ba449
...
...
@@ -34,8 +34,9 @@ static int get_input(t_list **commands)
return
(
SUCCESS
);
}
static
int
handle_execution
(
t_xe
*
xe
)
static
int
handle_execution
(
t_xe
*
xe
,
int
proc
)
{
int
i
;
int
ret
;
char
**
args
;
t_command
*
cur_command
;
...
...
@@ -65,8 +66,16 @@ static int handle_execution(t_xe *xe)
close
(
fd_pipe
[
1
]);
// error
dup2
(
fd_pipe
[
0
],
STDIN_FILENO
);
// error
free
(
cur_command
);
ret
=
handle_execution
(
xe
);
ret
=
handle_execution
(
xe
,
proc
+
1
);
close
(
fd_pipe
[
0
]);
// error
dup2
(
backup_stdin
,
STDIN_FILENO
);
i
=
0
;
while
(
i
<
proc
)
{
wait
(
NULL
);
i
++
;
}
dup2
(
backup_stdout
,
STDOUT_FILENO
);
return
(
ret
);
/*
cur_command = ft_lstshift(&(xe->commands));
...
...
@@ -91,8 +100,6 @@ static int handle_execution(t_xe *xe)
}
else
{
dup2
(
backup_stdin
,
STDIN_FILENO
);
dup2
(
backup_stdout
,
STDOUT_FILENO
);
return
(
SUCCESS
);
}
}
...
...
@@ -103,7 +110,7 @@ static int main_loop(t_xe *xe)
ret
=
get_input
(
&
xe
->
commands
);
if
(
ret
==
SUCCESS
)
ret
=
handle_execution
(
xe
);
ret
=
handle_execution
(
xe
,
0
);
return
(
ret
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment