Newsgroups: comp.sys.sgi
Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!aurora.physics.utoronto.ca!sysmark
From: sysmark@aurora.physics.utoronto.ca (Mark Bartelt)
Subject: Re: Pipes...
Message-ID: <1991May13.144102.2368@helios.physics.utoronto.ca>
Sender: news@helios.physics.utoronto.ca (News Administrator)
Nntp-Posting-Host: aurora.physics.utoronto.ca
Reply-To: mark@cita.toronto.edu
Organization: University of Toronto Physics/Astronomy/CITA
References: <4250.on.Fri,.10.May.91.20:53:34.EDT.@sct60a.sunyct.edu> <1991May12.010624.1808@dragon.wpd.sgi.com> <1991May13.133020.1580@helios.physics.utoronto.ca>
Date: Mon, 13 May 1991 14:41:02 GMT

Whoops, a minor bit of sloppiness in my previous posting.  At the very end
of the example parent process, I had

	close(PCW);
	close(CPR);

The example works as originally written, but it's really more proper to
call fclose() with the appropriate arguments, since we've done an fdopen()
on the file descriptors.  Also, a comment got dropped inadvertently.  So
the last section of the example parent process should look like:

	to_child   = fdopen(PCW,"w");	/* Parent process only */
	from_child = fdopen(CPR,"r");
	setlinebuf(to_child);
	while ( fgets(buf,BUFSIZE,stdin) != NULL ) {
		fputs(buf,to_child);
		fgets(buf,BUFSIZE,from_child);
		fputs(buf,stdout);
	}

	fclose(to_child);
	fclose(from_child);

There are undoubtedly other minor screwups in the example as well ...

Mark Bartelt                                                  416/978-5619
Canadian Institute for                               mark@cita.toronto.edu
Theoretical Astrophysics                             mark@cita.utoronto.ca
