Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int check(int code, const char *msg) {
  2. if (code == -1) {
  3. perror(msg);
  4. exit(0);
  5. }
  6. return code;
  7. }
  8. int msgCreate(key_t key) {
  9. return check(msgget(key, IPC_CREAT | IPC_EXCL | 0700), __FUNCTION__);
  10. }
  11. int msgOpen(key_t key) {
  12. return check(msgget(key, IPC_CREAT | 0700), __FUNCTION__);
  13. }
  14. int msgRemove(int msgId) {
  15. check(msgctl(msgId, IPC_RMID, NULL), __FUNCTION__);
  16. }
  17.  
  18. int msgSend(int msgid, void* msgp, size_t msgsz) {
  19. const int msgflg = 0;
  20. check(msgsnd(msgid, msgp, msgsz, msgflg), __FUNCTION__);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement