Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <limits.h>
- int main()
- {
- int fd[2];
- if (pipe(fd) < 0)
- {
- exit(EXIT_FAILURE);
- }
- fcntl(fd[1], F_SETFL, O_NONBLOCK);
- int bufs_count = 0;
- char BUF[PIPE_BUF];
- for(;;){
- int bytes_write = write(fd[1], BUF, PIPE_BUF);
- if(bytes_write < 1){
- break;
- }
- bufs_count += 1;
- }
- printf("pipe buffer size : %d\n", PIPE_BUF);
- printf("pipe buffers count : %d\n", bufs_count);
- printf("default pipe size : %d\n", bufs_count * PIPE_BUF);
- close(fd[0]);
- close(fd[1]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement