Skip to content

Instantly share code, notes, and snippets.

@aleqsio
Created April 24, 2018 20:14
Show Gist options
  • Save aleqsio/7a09c59730cf3bd09f5282c2cb1fcf43 to your computer and use it in GitHub Desktop.
Save aleqsio/7a09c59730cf3bd09f5282c2cb1fcf43 to your computer and use it in GitHub Desktop.
while (serverRunning) {
CHECK_IS_POSITIVE(msgrcv(publicServerQueueID, &readMessage, MESSAGE_SIZE, 0, 0));
runCommand(&readMessage);
}
struct msqid_ds queueState;
CHECK_IS_POSITIVE_ERROR(msgctl(publicServerQueueID, IPC_STAT, &queueState),"er0");
while (queueState.msg_qnum) {
CHECK_IS_POSITIVE_ERROR(msgctl(publicServerQueueID, IPC_STAT, &queueState),"ER1");
CHECK_FALSE(msgrcv(publicServerQueueID, &readMessage, MESSAGE_SIZE, 0, 0)<0,"Failed to read remaining commands");
runCommand(&readMessage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment