Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIPE_ID "aa"
- int Pipe_FD = 0;
- int main (int argc, char **argv)
- {
- printf("Waiting on openn");
- while(Pipe_FD = open(PIPE_ID, O_RDONLY) < 0) {
- }
- printf("waiting on readn");
- char ch;
- while(read(Pipe_FD, &ch, 1) > 0) {
- printf("Read: %ct", ch);
- fflush(stdout);
- }
- close(Pipe_FD);
- return 1;
- }
- #define PIPE_ID "aa"
- int Pipe_FD = 0;
- // This function configures named pipe
- void configure_pipe() {
- if(mkfifo(PIPE_ID, 0666) != 0) {
- perror("mkfifo errorn");
- }
- }
- void writeInPipe() {
- Pipe_FD = open(PIPE_ID, O_WRONLY);
- int num;
- if((num = write(Pipe_FD, "Hi", sizeof("Hi"))) < 0) {
- perror("Error in writingt");
- exit(-1);
- } else
- printf("Wrote bytes: %dn", num);
- close(Pipe_FD);
- }
- int main() {
- configure_pipe();
- writeInPipe();
- sleep(1);
- unlink(PIPE_ID);
- }
- Wrote bytes: 3
- Waiting on open
- waiting on read
- Read:
- Read:
- Read:
- a
- Read: a Read:
- ab
- Read: a Read: b Read:
Add Comment
Please, Sign In to add comment