1 #include <framework/pcore/SemaphoreLocker.h>
2 #include <framework/logging/Logger.h>
14 int semid = semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600);
18 if (semctl(semid, 0, SETVAL, semval) == -1) {
19 B2ERROR(
"Initializing semaphore with semctl() failed.");
21 }
else if (errno == EEXIST) {
22 semid = semget(semkey, 1, 0600);
25 B2ERROR(
"Couldn't create semaphore with semget()! Maybe you have too many semaphores from aborted processes lying around, you can clean those up by running 'clear_basf2_ipc'.");
34 if (semctl(semId, 1, IPC_RMID) == -1) {
35 B2ERROR(
"Error in SemaphoreLocker::destroy(), semaphore " << semId <<
", error: " << strerror(errno));
42 int val = semctl(semId, 0, GETVAL, ignored);
48 void doSemOp(
int semID,
int op)
54 while (semop(semID, &sb, 1) == -1) {
59 B2FATAL(
"Another process was aborted, please check previous output for reasons. (" <<
60 strerror(errno) <<
" for semaphore " << semID <<
")");