/* Test "popen" commands.

   I should be able to popen to "r"ead and eat up its stdout into the
   FILE * returned by mypopen.  I should also be able to send data to the
   FILE * if opened "w"rite and have the sub-process do something with it.
*/

#include <stdio.h>

char msg[] = "Hello there.\nThis is line2\n";


main()
{
    char *cp1, *cp2;
    char inbuf[1024];
    char backbuf[1024];
    FILE *fp, *mypopen();
    int p[2];

    fp = mypopen("cat s:startup-sequence", "r");
    while (fgets(inbuf, sizeof(inbuf), fp)) {
	cp2 = &backbuf[strlen(inbuf) - 1];	/* Skip \n\0 */
	*cp2-- = '\0';
	cp1 = inbuf;
	while (*cp1) *cp2-- = *cp1++;
	puts (backbuf);
    }
    mypclose(fp);
    exit(0);
}
