From 16092c007e8767b32c107d74d3ea3d238f5e65ec Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 6 Mar 2020 18:10:14 +0100 Subject: Preparing forks --- src/ft_treat_args.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ft_treat_args.c') 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 #include #include -#include #include 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)) -- cgit v1.2.3 From a35b258841cde7884f5bb71d5ae0951d5e3f27b7 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 6 Mar 2020 19:03:24 +0100 Subject: fork(3) going well, freed a leak --- src/ft_treat_args.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ft_treat_args.c') diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index b588b46..accf3aa 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -37,8 +37,13 @@ uint8_t return (ft_exit(FT_RET_FAILED_MLX, clist)); ft_draw_scene(clist); if (clist->mlist.ismusic) - ft_music_fork(cl); + { /* create music fork() here */ + clist->isoldmus = 1; + clist->mpid = fork(); + if (clist->mpid == 0) + ft_music_fork(clist->mlist.music_cmd); + } ft_hooks_and_loops(&clist->wlist, clist); } else if (argc == 3 && !ft_strncmp("--save", argv[2], 7)) -- cgit v1.2.3 From 6a89966eed6110d0e7a7ec53727c4473d18ad441 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 6 Mar 2020 20:43:42 +0100 Subject: Fuck execve --- src/ft_treat_args.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ft_treat_args.c') diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index accf3aa..c4ffc98 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -42,7 +42,7 @@ uint8_t clist->isoldmus = 1; clist->mpid = fork(); if (clist->mpid == 0) - ft_music_fork(clist->mlist.music_cmd); + ft_music_fork(clist->mlist.mcmd_words); } ft_hooks_and_loops(&clist->wlist, clist); } -- cgit v1.2.3 From 874d8d3bbafb3d1919cfc6f21fdb780382f0d015 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 6 Mar 2020 21:03:07 +0100 Subject: boy --- src/ft_treat_args.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ft_treat_args.c') diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index c4ffc98..79eedae 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -29,7 +29,7 @@ uint8_t } uint8_t - ft_use_args(int argc, const char *argv[], t_cub *clist) + ft_use_args(int argc, const char *argv[], char *const envp[], t_cub *clist) { if (argc < 3) { @@ -42,7 +42,7 @@ uint8_t clist->isoldmus = 1; clist->mpid = fork(); if (clist->mpid == 0) - ft_music_fork(clist->mlist.mcmd_words); + ft_music_fork(clist->mlist.mcmd_words, envp); } ft_hooks_and_loops(&clist->wlist, clist); } -- cgit v1.2.3 From 3048aae5d3f50359f19e0d440376ae422a16a7b7 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 6 Mar 2020 21:47:09 +0100 Subject: Good enough --- src/ft_treat_args.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/ft_treat_args.c') diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c index 79eedae..a47f9f7 100644 --- a/src/ft_treat_args.c +++ b/src/ft_treat_args.c @@ -31,18 +31,17 @@ uint8_t uint8_t ft_use_args(int argc, const char *argv[], char *const envp[], t_cub *clist) { + clist->envp = envp; if (argc < 3) { if (ft_init_winptr(clist) < 0) + { return (ft_exit(FT_RET_FAILED_MLX, clist)); + } ft_draw_scene(clist); if (clist->mlist.ismusic) { - /* create music fork() here */ - clist->isoldmus = 1; - clist->mpid = fork(); - if (clist->mpid == 0) - ft_music_fork(clist->mlist.mcmd_words, envp); + ft_enable_music(clist); } ft_hooks_and_loops(&clist->wlist, clist); } -- cgit v1.2.3