Creates or gets a semaphore set.
#include <sys/sem.h> int semget ( key_t key, int nsems, int semflag );
(IN) Specifies an existing key created with the ftok function or IPC_PRIVATE, a flag which allows a key to be created.
(IN) Specifies the number of semaphores for the set. When accessing an existing semaphore set, this parameter can be set to 0.
(IN) Specifies how to create the semaphore set with the following flags which can be ORed together:
If successful, returns a semaphore idenifier for the semaphore set; otherwise, returns -1 and sets errno to one of the following:
When a semaphore set is created, the array of sem structures is not initialized.
When accessing an existing semaphore set, the key parameter must specify the key associated with the set and the IPC_EXCL flag cannot be set in the semflg parameter.
A semaphore set created with a key value of IPC_PRIVATE is private to the process that created the key. Semaphores created with keys generated with the ftok function can be shared.
When you are finished with the semaphore set, you should remove it by calling the semctl function.