aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_warp_level.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-06 19:12:10 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-06 19:12:10 +0100
commitf3aab6429d673342f4819f8a3c2857e48610689a (patch)
tree58bdf90289a564a527feab138a61d1304ee9f1d1 /src/ft_warp_level.c
parentfork(3) going well, freed a leak (diff)
download42-cub3d-f3aab6429d673342f4819f8a3c2857e48610689a.tar.gz
42-cub3d-f3aab6429d673342f4819f8a3c2857e48610689a.tar.bz2
42-cub3d-f3aab6429d673342f4819f8a3c2857e48610689a.tar.xz
42-cub3d-f3aab6429d673342f4819f8a3c2857e48610689a.tar.zst
42-cub3d-f3aab6429d673342f4819f8a3c2857e48610689a.zip
it's going well
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r--src/ft_warp_level.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 0d126c1..febff7e 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -15,6 +15,9 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/wait.h>
#include <mlx.h>
static void
@@ -65,13 +68,18 @@ static void
{
if (isoldmus && !cl->mlist.ismusic)
{
- /* stop fork() here */
+ kill(cl->mpid, SIGTERM);
+ wait(&cl->mpid);
cl->isoldmus = 0;
}
else if (isoldmus && cl->mlist.ismusic
&& ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))
{
- /* stop and recreate fork() here */
+ kill(cl->mpid, SIGTERM);
+ wait(&cl->mpid);
+ cl->mpid = fork();
+ if (cl->mpid == 0)
+ ft_music_fork(cl->mlist.music_cmd);
}
else if (isoldmus && cl->mlist.ismusic
&& !ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))