diff options
Diffstat (limited to 'src/ft_music.c')
-rw-r--r-- | src/ft_music.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/ft_music.c b/src/ft_music.c index 234f86e..13da479 100644 --- a/src/ft_music.c +++ b/src/ft_music.c @@ -11,21 +11,28 @@ /* ************************************************************************** */ #include <cub3d.h> -#include <unistd.h> +#include <stddef.h> +#include <stdlib.h> +#include <pthread.h> void - ft_music_fork(char **mcmd_words, char *const envp[]) + *ft_music_thread(void *vargp) { - execve(*(mcmd_words + 0), mcmd_words, envp); + t_cub *cl; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + cl = (t_cub *)vargp; + while (1) + system(cl->mlist.music_cmd); + return(NULL); } void ft_enable_music(t_cub *cl) { cl->isoldmus = 1; - cl->mpid = fork(); - if (cl->mpid == 0) - { - ft_music_fork(cl->mlist.mcmd_words, cl->envp); - } + pthread_create(&cl->mtid, NULL, ft_music_thread, cl); } |