jfcmacro

destruirSemNomPosix.cpp

Mar 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <fcntl.h>
  3. #include <sys/stat.h>
  4. #include <semaphore.h>
  5. #include <unistd.h>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <cerrno>
  9.  
  10. using namespace std;
  11.  
  12. static void usage(char *progname);
  13.  
  14. int
  15. main(int argc, char *argv[]) {
  16.  
  17.   if (argc != 2) usage(argv[0]);
  18.  
  19.   sem_t *sem;
  20.  
  21.   if (sem_unlink(argv[1]) == -1) {
  22.     cerr << "Error borrando el semaforo: " <<
  23.       strerror(errno) << endl;
  24.     return EXIT_FAILURE;
  25.   }
  26.  
  27.   return EXIT_SUCCESS;
  28. }
  29.  
  30. static void usage(char *progname) {
  31.   cerr << "Uso: " << progname
  32.        << " <nombresem> "
  33.        << endl;
  34.   exit(EXIT_FAILURE);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment