Pipes...

Mark Bartelt sysmark at aurora.physics.utoronto.ca
Tue May 14 00:41:02 AEST 1991


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 at cita.toronto.edu
Theoretical Astrophysics                             mark at cita.utoronto.ca



More information about the Comp.sys.sgi mailing list