Article View: es.comp.os.linux.programacion
Article #1885PIPE buffer size unknown or ignored...
From: Blisseth Luther
Date: Fri, 08 Jul 2005 21:15
Date: Fri, 08 Jul 2005 21:15
69 lines
3310 bytes
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;
}
Technical Details
Message-ID:
<P1Cze.49703$h5.2082735@news3.tin.it>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.tin.it!news-in.tin.it!news3.tin.it.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f86c8,95a94ce0a189d483,start X-Google-Attributes: gidf86c8,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.tin.it!news-in.tin.it!news3.tin.it.POSTED!not-for-mail From: "Blisseth Luther" <junkmailsafe-1@yahoo.it> Newsgroups: es.comp.os.linux.programacion Subject: PIPE buffer size unknown or ignored... Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Original Message-ID: <P1Cze.49703$h5.2082735@news3.tin.it> Date: Fri, 08 Jul 2005 21:15:27 GMT NNTP-Posting-Host: 212.171.245.148 X-Complaints-To: "Please send abuse reports to abuse@tin.it and technical notifications to newsmaster@tin.it" X-Trace: news3.tin.it 1120857327 212.171.245.148 (Fri, 08 Jul 2005 23:15:27 MET DST) NNTP-Posting-Date: Fri, 08 Jul 2005 23:15:27 MET DST Organization: TIN