diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-16 19:41:26 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-16 19:41:26 +0100 |
commit | a8c9c04ec24a71f076891bdc1c26860db7c5c9c3 (patch) | |
tree | a5dc6905f6987c4d5fcd27276f7fc338f2af8f0b /src/ft_sfx_death.c | |
parent | Cleaner memdels (diff) | |
parent | Merge branch 'master' into back-to-pthread (diff) | |
download | 42-cub3d-a8c9c04ec24a71f076891bdc1c26860db7c5c9c3.tar.gz 42-cub3d-a8c9c04ec24a71f076891bdc1c26860db7c5c9c3.tar.bz2 42-cub3d-a8c9c04ec24a71f076891bdc1c26860db7c5c9c3.tar.xz 42-cub3d-a8c9c04ec24a71f076891bdc1c26860db7c5c9c3.tar.zst 42-cub3d-a8c9c04ec24a71f076891bdc1c26860db7c5c9c3.zip |
Merge branch 'back-to-pthread'
Diffstat (limited to 'src/ft_sfx_death.c')
-rw-r--r-- | src/ft_sfx_death.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/ft_sfx_death.c b/src/ft_sfx_death.c index 2566358..1680f2d 100644 --- a/src/ft_sfx_death.c +++ b/src/ft_sfx_death.c @@ -11,14 +11,30 @@ /* ************************************************************************** */ #include <cub3d.h> -#include <unistd.h> +#include <stdlib.h> +#include <pthread.h> void - ft_sfx_death(t_cub *cl) + *ft_sfx_death_thread(void *vargp) { - cl->sfx.death_pid = fork(); - if (cl->sfx.death_pid == 0) + t_sfx *sfx; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + sfx = (t_sfx *)vargp; + pthread_mutex_lock(&sfx->death_mutex); + while (1) { - execve(*(cl->sfx.death + 0), cl->sfx.death, cl->envp); + pthread_mutex_lock(&sfx->death_mutex); + system(sfx->death); } + return (NULL); +} + +void + ft_sfx_death(t_cub *cl) +{ + pthread_mutex_unlock(&cl->sfx.death_mutex); } |