diff options
Diffstat (limited to 'src/ft_sfx_new_level.c')
-rw-r--r-- | src/ft_sfx_new_level.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/ft_sfx_new_level.c b/src/ft_sfx_new_level.c index 05e9059..2cde15c 100644 --- a/src/ft_sfx_new_level.c +++ b/src/ft_sfx_new_level.c @@ -11,14 +11,31 @@ /* ************************************************************************** */ #include <cub3d.h> -#include <unistd.h> +#include <stdlib.h> +#include <pthread.h> void - ft_sfx_new_level(t_cub *cl) + *ft_sfx_new_lvl_thread(void *vargp) { - cl->sfx.new_lvl_pid = fork(); - if (cl->sfx.new_lvl_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->new_lvl_mutex); + while (1) { - execve(*(cl->sfx.new_lvl + 0), cl->sfx.new_lvl, cl->envp); + pthread_mutex_lock(&sfx->new_lvl_mutex); + if (system(sfx->new_lvl)) + pthread_exit(NULL); } + return (NULL); +} + +void + ft_sfx_new_level(t_cub *cl) +{ + pthread_mutex_unlock(&cl->sfx.new_lvl_mutex); } |