size of named pipe

Posted on 2001-07-26
Last Modified: 2013-12-27
Hi All!

I have a problem with named pipes. I'm only able to send 1024 bytes with putpmsg. If I try to send more I get an error (ERANGE).

How can I change the maximum size of named pipes ?
Question by:superschlonz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2

Expert Comment

ID: 6322255
Please look for strbuf in a file called stropts.h

On solaris this can be found in /usr/include/sys/stropts.h

Author Comment

ID: 6322808
I'm using this structure (also tried to set maxlen=len instead of zero).

And I'm sure I was able to send up to about 3000 bytes some days ago. But after a lot of changes in my source code I always get an ERANGE error when sending 2828 bytes.

I wrote a little testprogram to find out how many bytes are accepted and it shows 1024 (for control part which we use).
And it also shows that I can send 5120 bytes for the data part.

For sending the data we use the ctl part and I'm sure that I didn't touch that. OK, now I'll try sending the data in the data part, perhaps it works.

Author Comment

ID: 6322835
I saw, this would be very much work.

Is it possible to increase the maximum size of the ctl part ?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 6323915
Maybe you can find your answer here :

This example illustrates a simple loop, with the application reading data from the communications device, then writing the input back to the same device,
echoing all input back over the communications line. The program reads up to 1024 bytes at a time, and then writes the number of bytes just read.

read returns the available data, which can contain fewer than 1024 bytes. If no data is currently available at the stream head, read(2) blocks until data
Simple Stream

#include <sys/fcntl.h>
#include <stdio.h>
  char buf[1024];
  int fd, count;
   if ((fd = open("/dev/ttya", O_RDWR)) < 0) {
   perror("open failed");
  while ((count = read(fd, buf, sizeof(buf))) > 0) {
   if (write(fd, buf, count) != count) {
    perror("write failed");
LVL 14

Expert Comment

ID: 6326946
Pipe devices just aren't designed for this sort of thing.

You need  your writing program to buffer its output so it won't fill the pipe and you need your reading program to keep reading until it gets the whole thing.

Using stdio should solve the buffering problem easily enough.

If the reader knows the size of the structure it needs to read, then things are easy enough on the reading side too (just keep reading until you get the whole thing, as suggested by paulgna).  Otherwise you might need to prepend the structure with its size so the reader knows how much data it should expect to slurp up.

Author Comment

ID: 6331584
Perhaps they aren't designed for that but they support it (at least since 2.6 and ReliantUNIX/SINIX since 5.42).

I cannot replace the mechanism because I need these bands for sending priorized messages (and because the software is very old and very complex).

This complexity was also the reason why I believed why my changes had nothing to do with the messages sent over the pipe. Now that I found it, I was able to reduce the maximum size to about 900 bytes again as was before my changes and it works.

But I'm still interested in increasing the size because I'm sure I'll run into this problem again and will perhaps not be able to do such a small workaround like this time.

I have also seen some kernel parameters for setting the size for ctl and data part of these system calls, but they aren't set int my /etc/system and default to 64kB.
LVL 14

Accepted Solution

chris_calabrese earned 50 total points
ID: 6334420
You probably have to recompile the kernel to change this.  Don't remember what vbl deals with this anymore (used to know back when the default was 512 bytes and we used to change this all the time).

Author Comment

ID: 6486245
I hoped I wouldn't need to do that...

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question