Set pipe buffer size

前端 未结 3 514
庸人自扰
庸人自扰 2020-12-29 08:06

I have a C++ multithreaded application which uses posix pipes in order to perform inter thread communications efficiently (so I don\'t have to get crazy with deadlocks).

3条回答
  •  误落风尘
    2020-12-29 08:53

    Since you mentioned you are on Linux and may not mind non-portability, you may be interested in the file descriptor manipulator F_SETPIPE_SZ, available since Linux 2.6.35.

    int pipe_sz = fcntl(pipe_des[1], F_SETPIPE_SZ, sizeof(size_t));
    

    You'll find that pipe_sz == getpagesize() after that call, since the buffer cannot be made smaller than the system page size. See fcntl(2).

提交回复
热议问题