From 48ccff3d712a2b30de8b94a5688afae7ee91a1c6 Mon Sep 17 00:00:00 2001
From: JozanLeClerc <bousset.rudy@gmail.com>
Date: Mon, 2 Mar 2020 16:09:57 +0100
Subject: YES

---
 Makefile            | 4 ++--
 src/ft_exit.c       | 3 +++
 src/ft_music.c      | 1 -
 src/ft_treat_args.c | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index bc9c5fb..8f1b21c 100644
--- a/Makefile
+++ b/Makefile
@@ -128,7 +128,7 @@ ${OBJS_DIR}%.o:		${SRCS_DIR}%.c ${INCS_DIR}
 ifeq (${OS}, Darwin)
 	${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${MLX_DIR} -I${INCS_DIR} -o $@ $<
 else
-	${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} -o $@ $<
+	${CC} -c -pthread ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} -o $@ $<
 endif
 #--------------------------------------------------------------------------------------------------#
 ${NAME}:	${OBJS} ${LFT_SRCS} ${LFT_DIR}${INCS_DIR}libft.h
@@ -147,7 +147,7 @@ ifeq (${OS}, Darwin)
 	${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_DIR} -lft -lmlx -lm -framework OpenGL \
 -framework AppKit
 else
-	${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -lft -lX11 -lXext -lmlx -lm -lbsd -pthread
+	${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -lft -lX11 -lXext -lmlx -lm -lbsd -lpthread
 endif
 #--------------------------------------------------------------------------------------------------#
 all: ${NAME}
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 493e00f..d4fb4f9 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <pthread.h>
 
 static void
 	ft_free_lists(t_cub *clist)
@@ -63,6 +64,8 @@ int
 	}
 	ft_free_lists(clist);
 	ft_printf("Exiting program\n");
+	pthread_cancel(clist->tid);
+	pthread_exit(NULL);
 	exit(exit_code);
 	return (0);
 }
diff --git a/src/ft_music.c b/src/ft_music.c
index cc8d1ca..a4d588a 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -37,7 +37,6 @@ void
 	ft_printf("\n\n========= QWEQWE =========\n%s\n", cmd);
 	system(cmd);
 	ft_memdel((void**)&cmd);
-	pthread_exit(NULL);
 	return (NULL);
 }
 
diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c
index dab29ac..25c56d1 100644
--- a/src/ft_treat_args.c
+++ b/src/ft_treat_args.c
@@ -40,6 +40,7 @@ uint8_t
 		if (clist->mlist->ismusic)
 		{
 			pthread_create(&clist->tid, NULL, ft_music_thread, clist);
+			/* ft_music_thread(clist); */
 		}
 		ft_hooks_and_loops(clist->wlist, clist);
 	}
-- 
cgit v1.2.3