Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int check(int code, const char *msg) {
- if (code == -1) {
- perror(msg);
- exit(0);
- }
- return code;
- }
- int msgCreate(key_t key) {
- return check(msgget(key, IPC_CREAT | IPC_EXCL | 0700), __FUNCTION__);
- }
- int msgOpen(key_t key) {
- return check(msgget(key, IPC_CREAT | 0700), __FUNCTION__);
- }
- int msgRemove(int msgId) {
- check(msgctl(msgId, IPC_RMID, NULL), __FUNCTION__);
- }
- int msgSend(int msgid, void* msgp, size_t msgsz) {
- const int msgflg = 0;
- check(msgsnd(msgid, msgp, msgsz, msgflg), __FUNCTION__);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement