aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d_structs.h2
-rw-r--r--src/ft_exit.c5
-rw-r--r--src/ft_music.c14
-rw-r--r--src/ft_treat_args.c4
-rw-r--r--src/ft_warp_level.c9
5 files changed, 12 insertions, 22 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index c74a9e0..7e49e14 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -177,7 +177,7 @@ typedef struct s_cub
uint16_t i;
char errmsg[64];
int32_t key_input[5];
- pthread_t tid;
+ pid_t mpid;
int (*key_ptr[6])(struct s_cub*);
int8_t (*get_ptr[11])(char**, struct s_cub*);
struct s_win wlist;
diff --git a/src/ft_exit.c b/src/ft_exit.c
index ca5201c..c7b2275 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -16,8 +16,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
-#include <signal.h>
-#include <pthread.h>
static void
ft_free_lists(t_cub *clist)
@@ -67,8 +65,7 @@ int
}
if (clist->isoldmus && clist->wlist.inited)
{
- pthread_cancel(clist->tid);
- pthread_join(clist->tid, NULL);
+ /* kill fork() here */
}
ft_free_lists(clist);
ft_printf("Exiting program\n");
diff --git a/src/ft_music.c b/src/ft_music.c
index aec5e58..b9e9d89 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -14,17 +14,15 @@
#include <cub3d.h>
#include <stddef.h>
#include <stdlib.h>
-#include <pthread.h>
void
- *ft_music_thread(void *vargp)
+ ft_music_fork(t_cub *cl)
{
- t_cub *cl;
-
- cl = (t_cub *)vargp;
cl->isoldmus = 1;
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
while (1)
- system(cl->mlist.music_cmd);
- return (NULL);
+ {
+ ft_printf("qweqwe\n");
+ }
+ /* system(cl->mlist.music_cmd); */
+ /* execve here */
}
diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c
index 2571709..b588b46 100644
--- a/src/ft_treat_args.c
+++ b/src/ft_treat_args.c
@@ -14,7 +14,6 @@
#include <cub3d.h>
#include <stddef.h>
#include <stdint.h>
-#include <pthread.h>
#include <unistd.h>
uint8_t
@@ -38,7 +37,8 @@ uint8_t
return (ft_exit(FT_RET_FAILED_MLX, clist));
ft_draw_scene(clist);
if (clist->mlist.ismusic)
- pthread_create(&clist->tid, NULL, ft_music_thread, clist);
+ ft_music_fork(cl);
+ /* create music fork() here */
ft_hooks_and_loops(&clist->wlist, clist);
}
else if (argc == 3 && !ft_strncmp("--save", argv[2], 7))
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 808b346..4d1ca12 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -16,8 +16,6 @@
#include <stddef.h>
#include <stdint.h>
#include <mlx.h>
-#include <signal.h>
-#include <pthread.h>
static void
ft_del_map(t_map *ml)
@@ -66,16 +64,13 @@ static void
{
if (isoldmus && !cl->mlist.ismusic)
{
- pthread_cancel(cl->tid);
- pthread_join(cl->tid, NULL);
+ /* stop fork() here */
cl->isoldmus = 0;
}
else if (isoldmus && cl->mlist.ismusic
&& ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))
{
- pthread_cancel(cl->tid);
- pthread_join(cl->tid, NULL);
- pthread_create(&cl->tid, NULL, ft_music_thread, cl);
+ /* stop and recreate fork() here */
}
else if (isoldmus && cl->mlist.ismusic
&& !ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))