summaryrefslogtreecommitdiff
path: root/tests/integration/project/files/test_shm.c
blob: 4ee71cb2b36a36f11882dfce4c086115840977dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>

int main ()
{
  int fd = shm_open ("/foo", O_RDONLY | O_CREAT, S_IRWXU);
  if (fd < 0)
  {
    fprintf (stderr, "Failed to open shm: %s\n", strerror (errno));
    exit(1);
  }

  int success = shm_unlink ("/foo");
  if  (success < 0)
  {
    fprintf (stderr, "Failed to close shm: %s\n", strerror (errno));
    exit(2);
  }

  close (fd);

  return 0;
}