semaphore.h does'nt include fcntl.h ?

Dan Nelson dnelson at allantgroup.com
Mon Jan 15 01:41:42 UTC 2007


In the last episode (Jan 14), girish r said:
> I am trying to use sem_open(3) but gcc complains that O_CREAT and
> O_EXCL is undeclared. According to the man page only semaphore.h
> needs to be included. But including fcntl.h solves the problem.

Looks like a semaphore.h needs to define O_CREAT and O_EXCL (just
having it include fcntl.h looks to be okay according to
http://www.opengroup.org/onlinepubs/009695399/basedefs/semaphore.h.html )
 
> sem_t *lock = sem_open("example_lock", O_CREAT | O_EXCL, 0600, 1);
> Another thing, a program with the above function call compiles but
> when I execute it, it spits out "Bad system call (core dump)".
> Specifically, I am trying to run this program given here:
> "http://www.informit.com/articles/article.asp?p=679545&seqNum=3&rl=1".

You'll need to include "options P1003_1B_SEMAPHORES" in your kernel
config, or load the "sem" kernel module.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-hackers mailing list