Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #define MSG_SIZE 80
- #define PIPENAME "./tmp/named_pipe_file"
- int main(void) {
- char msg[MSG_SIZE];
- int fd;
- int nread, i;
- if ((fd = open(PIPENAME, O_WRONLY)) < 0) {
- printf("fail to open named pipe\n");
- return 0;
- }
- for (i = 0; i < 3; i++) {
- fgets(msg, MSG_SIZE, stdin);
- if ((nread = write(fd, msg, sizeof(msg))) < 0 ) {
- printf("fail to call write()\n");
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement