Dima
Dima

Reputation: 1311

Increase pipe internal buffer size on CentOS

I'm using asynchronous pipes for inter-process communication (I removed error checks for simplification)

int pipe_fd[2];
pipe(pipe_fd);
int fdflags = fcntl(pipe_fd[1], F_GETFL, 0);
fdflags |= O_NONBLOCK;
fcntl(pipe_fd[1], F_SETFL, fdflags);

I'm looking for a way to increase pipe internal buffer size. I know that it is possible to do with Kernel >= 2.6.35 by the following way:

fcntl(fd, F_SETPIPE_SZ, size);

or by writing to:

/proc/sys/fs/pipe-max-size

But I'm working on CentOS 5 with Kernel 2.6.18. Is it possible to increase pipe internal buffer size with Kernel 2.6.18? If yes, how to do that?

Upvotes: 1

Views: 5064

Answers (3)

Marcelo Pacheco
Marcelo Pacheco

Reputation: 1

/proc/sys/fs/pipe-max-size sets the limit for fcntl F_SETPIPE_SZ

just changing /proc/sys/fs/pipe-max-size makes no diference ulimit -p also is useless

you must actually use fcntl F_SETPIPE_SZ

from what I've seen pipe-max-size default is 1MB, which should be more than plenty for any crazy pipe needs

Upvotes: 0

Dima
Dima

Reputation: 1311

On the kernel of CentoS 5, a pipe is fixed at 64 KB

Upvotes: 1

PoP
PoP

Reputation: 2165

Unless you only want to do this in your C code, one option is to use ulimit -p in a wrapper shell script that runs your program after setting the limit.

Upvotes: 0

Related Questions