This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Limit to size of pipe


Further to an earlier message I sent, I now attach an example. This tries to send a message of a fixed sized down a pipe. Under windows I can't seem to send much more than 25k down in one go, although I can send more if I chop it up into sections. Under linux however I can send as large amounts as I like. While it is possible to work around it, I thought I would mention it in case it was easy to fix, just no-one had requested it :)

Example program follows: setting MSGSIZE>25000ish on my computer causes fail (ie pipeval=-1)
#include <unistd.h>
#include <stdio.h>
#define MSGSIZE 23000
char *msg1 = "message";

void main(void) {
 char inbuf[MSGSIZE];
 int p[2], j;
 int pid;
 if(pipe(p) == -1) exit(1);

 switch(pid = fork()){
 case -1:    exit(2);
 case 0:  /* if child then write down pipe */
   close(p[0]);  /* first close the read end of the pipe */
   write(p[1], msg1, MSGSIZE);
 default:   /* parent reads pipe */
   close(p[1]);  /* first close the write end of the pipe */
   int pipeval=read(p[0], inbuf, MSGSIZE);
   printf("Parent sent: %s\n", inbuf);

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]