jfcmacro icon

CrearSemFumadores.cpp

jfcmacro | PRO | 03/22/19 04:52:08 PM UTC | 0 ⭐ | 479 👁️ | Never ⏰ | []
C++ |

610 B

|

None

|

0 👍

/

0 👎

#include <fcntl.h>           /* For O_* constants */
#include <sys/stat.h>        /* For mode constants */
#include <semaphore.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include "nombres.h"
 
using namespace std;
 
int
main(void) {
  sem_t *semaforos[nSEM];
 
  for (int i = 0; i < nSEM; ++i) {
    semaforos[i] = sem_open(nombres[i],
                O_CREAT | O_EXCL,
                S_IRUSR | S_IWUSR  | S_IRGRP | S_IWGRP, 0);
    if (semaforos[i] == nullptr) {
      cerr << "Error creando los semaforos: " << strerror(errno) << endl;
    }
 
    sem_close(semaforos[i]);
  }
 
  return EXIT_SUCCESS;
}

Comments