From: Lukas Jiriste Date: Tue, 28 May 2024 12:25:28 +0000 (+0200) Subject: Fix the hunger_watcher loop X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=5e460a2ac4dd12d2d7becc6ed86a6b71ce3633bf;p=42%2Fphilosophers.git Fix the hunger_watcher loop The hunger_watcher should exit its loop when philo has no time left. --- diff --git a/philo_bonus/hunger_watcher.c b/philo_bonus/hunger_watcher.c index 254dfd8..03edef8 100644 --- a/philo_bonus/hunger_watcher.c +++ b/philo_bonus/hunger_watcher.c @@ -36,7 +36,7 @@ static void *watch_for_starvation(void *philo_void) philo = philo_void; sem_wait(philo->philo_sem); time = time_till_death(philo); - while (time == 0) + while (time > 0) { sem_post(philo->philo_sem); usleep(time / 2);