fork download
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <semaphore.h>
  4.  
  5. int main() {
  6. sem_t *semaphore;
  7. int x;
  8.  
  9. semaphore = sem_open("example_semaphore", O_CREAT, 0644, 1);
  10.  
  11. // Use semaphore
  12. x++;
  13.  
  14. sem_close(semaphore); // Close semaphore
  15. sem_unlink("example_semaphore"); // Unlink semaphore from the system
  16. return 0;
  17. }
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty