diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 18:35:35 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 18:35:35 +0100 |
commit | 08d582c67c8ed4325325feb5ae29d64b7b46b958 (patch) | |
tree | d5a24a4f2226335ada4822655b574d7ca87be16a /src/ft_sfx_trap.c | |
parent | Not ideal (diff) | |
download | 42-cub3d-08d582c67c8ed4325325feb5ae29d64b7b46b958.tar.gz 42-cub3d-08d582c67c8ed4325325feb5ae29d64b7b46b958.tar.bz2 42-cub3d-08d582c67c8ed4325325feb5ae29d64b7b46b958.tar.xz 42-cub3d-08d582c67c8ed4325325feb5ae29d64b7b46b958.tar.zst 42-cub3d-08d582c67c8ed4325325feb5ae29d64b7b46b958.zip |
Fuck fork()
Diffstat (limited to '')
-rw-r--r-- | src/ft_sfx_trap.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ft_sfx_trap.c b/src/ft_sfx_trap.c index cf5dafa..dc998da 100644 --- a/src/ft_sfx_trap.c +++ b/src/ft_sfx_trap.c @@ -10,9 +10,11 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <unistd.h> #include <stdint.h> +#include <sys/wait.h> static void ft_sfx_pain(t_cub *cl) @@ -25,7 +27,12 @@ static void if (ref % 2) { cl->sfx.pain_pid = fork(); - if (cl->sfx.pain_pid == 0) + if (cl->sfx.pain_pid < 0) + { + ft_printf("Pain fork error\n"); + return ; + } + else if (cl->sfx.pain_pid == 0) { if (ref % 3) execve(*(cl->sfx.pain_one + 0), cl->sfx.pain_one, cl->envp); @@ -39,7 +46,15 @@ void ft_sfx_trap(t_cub *cl) { cl->sfx.trap_pid = fork(); - if (cl->sfx.trap_pid == 0) + if (cl->sfx.trap_pid < 0) + { + ft_printf("Trap fork error\n"); + return ; + } + else if (cl->sfx.trap_pid == 0) execve(*(cl->sfx.trap + 0), cl->sfx.trap, cl->envp); - ft_sfx_pain(cl); + else + { + ft_sfx_pain(cl); + } } |