aboutsummaryrefslogtreecommitdiff
path: root/philo_one/src/main.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-01-01 13:58:10 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-01-01 13:58:10 +0100
commit83df2b3a49bd3f627ae304bb1529e27d9b2d988c (patch)
tree3e1034909614101ebe27bc22ff4d56cea8d2baf9 /philo_one/src/main.c
parent632b7d81d6c7943e5e39812068c77df4681ebed2 (diff)
downloadphilosophers-83df2b3a49bd3f627ae304bb1529e27d9b2d988c.tar.gz
philosophers-83df2b3a49bd3f627ae304bb1529e27d9b2d988c.tar.bz2
philosophers-83df2b3a49bd3f627ae304bb1529e27d9b2d988c.zip
Fixing philo_one segfault because not checking correctly if finished
Diffstat (limited to 'philo_one/src/main.c')
-rw-r--r--philo_one/src/main.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/philo_one/src/main.c b/philo_one/src/main.c
index 0c4b95c..5ee4ba5 100644
--- a/philo_one/src/main.c
+++ b/philo_one/src/main.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/24 05:53:02 by cacharle #+# #+# */
-/* Updated: 2020/12/31 19:22:08 by charles ### ########.fr */
+/* Updated: 2021/01/01 13:43:46 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -60,10 +60,11 @@ int main(int argc, char **argv)
free(philos);
return (1);
}
- while (conf.all_alive)
- if (conf.meal_num != -1 && conf.meal_num_finished_counter == conf.philo_num)
- break;
- conf.all_alive = false;
+ while (!philo_finished(&conf))
+ ;
+ /* if (conf.meal_num != -1 && conf.meal_num_finished_counter == conf.philo_num) */
+ /* break; */
+ /* conf.all_alive = false; */
philos_detach(philos, conf.philo_num);
forks_destroy(forks, conf.philo_num);
pthread_mutex_destroy(&conf.mutex_stdout);