Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/msg.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <iostream>
- #include <fcntl.h>
- int main()
- {
- key_t key = ftok("/tmp/msg.temp", 1);
- int msgid = msgget(key, IPC_CREAT|IPC_EXCL|0777);
- msgbuf msg;
- int size = msgrcv(msgid, &msg, 81, 0, 0);
- int fd = open("/home/box/message.txt", O_RDWR|O_CREAT);
- write(fd, msg.mtext, size);
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement