From owner-FreeBSD-users-jp@jp.freebsd.org  Tue Apr 25 01:09:32 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id BAA08333;
	Tue, 25 Apr 2000 01:09:32 +0900 (JST)
	(envelope-from owner-FreeBSD-users-jp@jp.FreeBSD.org)
Received: from suri.co.jp (gateway.suri.co.jp [210.253.159.1])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id BAA08328
	for <FreeBSD-users-jp@jp.freebsd.org>; Tue, 25 Apr 2000 01:09:31 +0900 (JST)
	(envelope-from hide@koie.org)
Received: by gateway.suri.co.jp id <29572>; Tue, 25 Apr 2000 01:22:40 +0900
Message-Id: <00Apr25.012240jst.29572@gateway.suri.co.jp>
To: FreeBSD-users-jp@jp.freebsd.org
Cc: matsu@kiryu.co.jp
From: KOIE Hidetaka (=?iso-2022-jp?B?GyRCOHE5PjFRTjQbKEI=?=) <hide@koie.org>
In-Reply-To: <20000424224707Z.matsu@jp.freebsd.org>
References: <20000424224707Z.matsu@jp.freebsd.org>
X-Mailer: Mew version 1.95b34 on Emacs 20.5 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Date: Tue, 25 Apr 2000 01:22:34 +0900
Reply-To: FreeBSD-users-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: FreeBSD-users-jp 51361
Subject: [FreeBSD-users-jp 51361] RE: pipe
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org
X-Originator: hide@koie.org

From: Matsumura Naoki <matsu@kiryu.co.jp>
Subject: [FreeBSD-users-jp 51357] pipe(2)
Date: Mon, 24 Apr 2000 23:04:38 +0900

  | $B<ALd(B1. $B$3$l$r%3%^%s%I%i%$%s$+$i<B9T$9$k$H!"@5>o$KF0:n$7$F$$$k$h$&$K(B
  |        $B8+$($k$N$G$9$,!"(B% a.out > foo $B$J$I$H%j%@%$%l%/%H$9$k$H!"F1$89T$,(B
  |        $B2?EY$b=PNO$5$l$F$7$^$$$^$9!#$3$l$O$J$<$G$7$g$&$+!#$I$&$7$F(B
  |        $B%j%@%$%l%/%H$9$k$+$I$&$+$G5sF0$,0c$&$N$G$7$g$&$+!#(B

read_buf()$B$G0u;z$7$?FbMF$,%P%C%U%!%j%s%0$5$l$?$^$^%W%m%;%9$,@8@.$5$l(B
$B;R%W%m%;%9$N(Bexit()$B$N$H$-$K(Bfflush(stdout)$B$5$l$A$c$&$?$a!#(B

--- bar.c.org	Tue Apr 25 01:01:41 2000
+++ bar.c	Tue Apr 25 01:06:57 2000
@@ -5,15 +5,15 @@
 #include <sys/uio.h>
 #include <sys/wait.h>
 
-FILE *pread;  /* pipe read */
+FILE *xread;  /* pipe read */
 int pipes[2];
 
-/* pread (pipes[0]) $B$+$i(B1$B9TFI$_9~$`(B */
+/* xread (pipes[0]) $B$+$i(B1$B9TFI$_9~$`(B */
 
 void read_buf(){
     char buf[256];
 
-    fgets(buf,sizeof(buf),pread);
+    fgets(buf,sizeof(buf),xread);
     printf("Parent: %s",buf);
 }
 
@@ -27,9 +27,10 @@ main(){
 
     pipe(pipes); /* pipes[1] $B$K=q$-9~$`$s$@$b$N$,(B pipes[0] $B$+$iFI$a$k(B */
 
-    pread = fdopen(pipes[0],"r"); /* $B%U%!%$%k%G%#%9%/%j%W%?$+$i(B FILE * $B$r@8@.(B */
+    xread = fdopen(pipes[0],"r"); /* $B%U%!%$%k%G%#%9%/%j%W%?$+$i(B FILE * $B$r@8@.(B */
 
     for ( i=0 ; i<loop ; i++ ){
+        fflush(stdout);
         pid = fork();
         if ( pid == 0 ){   /* $B;R%W%m%;%9(B */
             close(pipes[0]);

#See manpage pread(2)

  | $B<ALd(B2. $B$=$b$=$b!"$3$&$$$&$U$&$K0l$D$N%U%!%$%k%G%#%9%/%j%W%?08$K(B
  |        $BJ#?t%W%m%;%9$,=PNO$9$k!"$H$$$&$3$H$O9T$J$C$F$b$h$$$N$G$7$g$&$+!#(B

$B$b$A$m$s$3$l$O(Bok.

--
KOIE Hidetaka $B8q9>1QN4(B <hide@koie.org>
