Path: blob/master/philo_bonus/ft_start_semaphores_bonus.c
882 views
/* ************************************************************************** */1/* */2/* ::: :::::::: */3/* ft_start_semaphores_bonus.c :+: :+: :+: */4/* +:+ +:+ +:+ */5/* By: yabtaour <[email protected]> +#+ +:+ +#+ */6/* +#+#+#+#+#+ +#+ */7/* Created: 2022/05/23 00:08:20 by yabtaour #+# #+# */8/* Updated: 2022/05/23 00:08:22 by yabtaour ### ########.fr */9/* */10/* ************************************************************************** */11#include "philosophers_bonus.h"1213int ft_start_semaphores(t_data *data)14{15sem_unlink("philo_forks");16sem_unlink("philo_output");17sem_unlink("philo_eat");18data->fork = sem_open("philo_forks", O_CREAT, 0700, data->philos_num);19data->eat = sem_open("philo_eat", O_CREAT, 0700, 1);20data->output = sem_open("philo_output", O_CREAT, 0700, 1);21if (data->fork == SEM_FAILED22|| data->eat == SEM_FAILED || data->output == SEM_FAILED)23{24ft_destroy_sem(data);25free(data);26exit (1);27}28return (1);29}303132