diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_exit.c | 2 | ||||
-rw-r--r-- | src/ft_music.c | 3 | ||||
-rw-r--r-- | src/ft_warp_level.c | 12 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c index 3ba1237..973abca 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -16,6 +16,7 @@ #include <stddef.h> #include <stdlib.h> #include <signal.h> +#include <sys/wait.h> #include <stdint.h> static void @@ -67,6 +68,7 @@ int if (clist->isoldmus && clist->wlist.inited) { kill(clist->mpid, SIGTERM); + wait(&clist->mpid); } ft_free_lists(clist); ft_printf("Exiting program\n"); diff --git a/src/ft_music.c b/src/ft_music.c index 70bb1a1..4d25a3a 100644 --- a/src/ft_music.c +++ b/src/ft_music.c @@ -19,10 +19,9 @@ void ft_music_fork(char *music_cmd) { - (void)music_cmd; while (1) { - ft_printf("qweqwe\n"); + ft_printf("%s\n", music_cmd); sleep(1); } /* execve here */ 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)) |