diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-15 01:02:32 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-15 01:02:32 +0100 |
commit | 9f35e7fab50809cd74e3bfffff67a81023abc837 (patch) | |
tree | 8ed891643db7c95aa7f72a1bab2a5f02efbbd078 /src/ft_music.c | |
parent | Looks like I have to pthread this shit (diff) | |
download | 42-cub3d-9f35e7fab50809cd74e3bfffff67a81023abc837.tar.gz 42-cub3d-9f35e7fab50809cd74e3bfffff67a81023abc837.tar.bz2 42-cub3d-9f35e7fab50809cd74e3bfffff67a81023abc837.tar.xz 42-cub3d-9f35e7fab50809cd74e3bfffff67a81023abc837.tar.zst 42-cub3d-9f35e7fab50809cd74e3bfffff67a81023abc837.zip |
I need a macOS
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); } |