The short C program below formats data for display as a piechart. I've included a brief set of docs after the source code, in latex format. There is no facility to watch the output of a program. The following function sends a command to gnuplot. Gnuplot will execute the command just as if you typed it at the gnuplot command line.
Complete source is included.
It should work with gawk or nawk, although I've only tested it with gawk. You just specify how many rows and columns of plots you want and it does the rest. Also, see the comments in the file. Massive patch with add multiplotcapability to all devices and a lot more. The reason it is offered in this form is because the original multiplot.pat did not patch correctly into gnuplot version 3.5.