🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: es.comp.os.linux.programacion
1 messages
1 total messages Started by Blisseth Luther Fri, 08 Jul 2005 21:15
PIPE buffer size unknown or ignored...
#1885
Author: Blisseth Luther
Date: Fri, 08 Jul 2005 21:15
69 lines
3310 bytes
This program should fill pipe buffer till it's full (after it must be killed
pressing ^C):
the last printf displayed should contain "ITERATION #" where # is equal to
the value of pipe buffer size.
I've read on man pages that "fpathconf(child2parent[1],_PC_PIPE_BUF)" gives
this value but I've tried to run this program and the last iteration has
# bigger than pipe buffer size:

     fpathconf returns 4096 bytes but
               # = 65536 on Debian, Knoppix 3.81 and 3.9 (derived from
                                     Debian) and Ufficio Zero 0.4.2 (derived
                                     from Arch Linux)
               # = 4096 on Pentoo 2005.1 (derived from Gentoo) and
                                   SimplyMepis 3.3.1 (derived from Debian)

Why??????
fpathconf doesn't returns pipe buffer size or it does but write writes more
than once _PC_PIPE_BUF bytes???

PLEASE REPLY ME VIA MAIL BECAUSE I CAN'T CHECK ALL THESE NEWSGROUPS.
THANKS!!!



#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <limits.h>
#include <unistd.h>

inline void sys_err(char *str)
{
     perror(str);
     exit(1);
}

int main()
{
     int child2parent[2],pid,i;
     char ch='\0';
     if (pipe(child2parent)<0)
          sys_err("\nPipe creation error!\n");
     printf("\nFather has PID %d\n",getpid());
     if ((pid=fork())<0)
          sys_err("\nFork error!\n");
     if (pid==0)
     {
          close(child2parent[0]);
          for (i=1;;i++)
          {
               if (write(child2parent[1],&ch,sizeof(ch))<=0)
                    sys_err("\nWrite error!\n");
               if (i==_POSIX_PIPE_BUF || i==_POSIX_PIPE_BUF+1 ||
                   i==PIPE_BUF || i>=PIPE_BUF+1)
               {
                    printf("\nChild has PID %d and father with ",getpid());
                    printf("PID %d   (ITERATION %d)\n\t",getppid(),i);
                    printf("_POSIX_PIPE_BUF=%d\t",_POSIX_PIPE_BUF);
                    printf("PIPE_BUF=%d\t",PIPE_BUF);
                    printf("fpathconf on _PC_PIPE_BUF returns=%ld\n",\
                             fpathconf(child2parent[1],_PC_PIPE_BUF));
               }
          }
     }
     close(child2parent[1]);
     wait(0);
     return 0;
} 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads