diff options
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r-- | src/ft_warp_level.c | 12 |
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)) |