Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <string.h>
- #include <sys/stat.h>
- #include <sys/ioctl.h>
- int main()
- {
- int out, in, err;
- char *cFifo = "/tmp/out";
- char *cInFifo = "/tmp/in";
- mkfifo(cFifo, S_IRUSR|S_IWUSR);
- mkfifo(cInFifo, S_IRUSR|S_IWUSR);
- out = open(cFifo, O_RDWR|O_TRUNC|O_NONBLOCK);
- in = open(cInFifo, O_RDWR|O_TRUNC|O_NONBLOCK);
- dup2(out, STDOUT_FILENO);
- dup2(out, STDERR_FILENO);
- dup2(in, STDIN_FILENO);
- scanf("%*c");
- while(1)
- {
- scanf("%*c");
- printf("Hellon");
- fflush(stdout);
- }
- return 0;
- }
- #include <stdio.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/stat.h>
- #include <sys/ioctl.h>
- int main()
- {
- int out, in;
- size_t i = 0;
- char bufOut[1024];
- char *cFifo = "/tmp/out";
- char *cFifoIn = "/tmp/in";
- out = open(cFifo, O_RDONLY);
- in = open(cFifoIn, O_WRONLY);
- while(1)
- {
- i =0;
- while(!i)
- {
- i = read(out, bufOut, 1024);
- }
- if(i)
- write(STDOUT_FILENO, bufOut, i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement