title: Posting to a POSIX semaphore using JNA
body: <p>I am trying to post to a semaphore using JNA on a Linux machine. For some reason, I always receive a 22 error (invalid argument) even for this simple example. In my understanding, should the below code not open a POSIX semaphore, post to it and close it again?</p>
  
  <pre><code>public class Sample {
  
    private static final int O_CREAT = 0x40;
  
    public static void main(String[] args) throws Exception {
      File notifier = new File("/tmp", "_test" + new Random().nextInt());
        if (!notifier.isFile() &amp;&amp; !notifier.createNewFile()) {
          throw new IllegalStateException("Could not create notifier: " + notifier);
        }
  
        SempahoreLibrary library = Native.load("c", SempahoreLibrary.class);
        Pointer semaphore = library.sem_open(notifier.getAbsolutePath(), O_CREAT, 666, 0);
        try {
          library.sem_post(semaphore);
        } finally {
          library.sem_close(semaphore);
        }
    }
  
    interface SempahoreLibrary extends Library {
      Pointer sem_open(String name, int flags, int mode, int value) throws LastErrorException;
      int sem_post(Pointer pointer) throws LastErrorException;
      int sem_close(Pointer pointer) throws LastErrorException;
    }
  }
  </code></pre>