Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Feb 2004 22:16:37 +0100
From:      Eric Jacoboni <jaco@scrogneugneu.org>
To:        freebsd-questions@freebsd.org
Subject:   sem_open(3) and FBSD 5.2 : what the point ?
Message-ID:  <40240435.3080707@scrogneugneu.org>

next in thread | raw e-mail | index | archive | help
Hi,

Here's a sample code:

#include <stdio.h>
#include <semaphore.h>

int main(void) {

    sem_t *dis_ping, *dis_pong;

    dis_ping = sem_open("/ping.sem", O_CREAT, 0777, 1);
    dis_pong = sem_open("/pong.sem", O_CREAT, 0777, 0);

    for(;;) {
      sem_wait(dis_ping);
      puts("Ping...");
      sem_post(dis_pong);
    }

    sem_close(dis_ping);
    sem_close(dis_pong);

    return 0;
}

This code compiles and works fine on Darwin...

On FBSD 5.2, gcc first complains it doesn't know about O_CREAT... That's 
not what the sem_open() manpage claims but, ok, let's include <fcntl.h>.

The code, then, compile ok, but fails on :

$ ./ping.exe
zsh: invalid system call (core dumped)  ./ping.exe

Any idea?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40240435.3080707>