Problems with popen on RS/6000

Peter Mroz mroz at eplrx7.uucp
Thu Aug 16 06:32:39 AEST 1990


I'm having a problem with popen sending back buffered output.  I am in the
process of writing a program to display vmstat output using curses.  However,
when I issue the command

	vin = popen("vmstat 2","r");

I can't read anything with fgets until some internal buffer is filled.  I
tried running the same program on a Sun and it works just fine.  Any suggestions
would be appreciated.

On the IBM RS/6000 the following program doesn't send back any vmstat output
until 30 seconds have passed.  On the Sun it sends output back every second,
like I thought it would.

/* testp.c */
#include <stdio.h>
#include <signal.h>

char *progname;		/* program name for error messages */

main (argc, argv)
	int argc;
	char *argv[];
{

	FILE *vin, *popen();
	char *vmstat_cmd = "vmstat 1 30";
	char input_line[BUFSIZ];

	progname = argv[0];
	if ((vin = popen(vmstat_cmd, "r")) == NULL)
	{
		fprintf(stderr, "%s: can't run %s\n", progname, vmstat_cmd);
		exit(1);
	}

	printf("\nOK.  Pipe initialized \n");

	fgets(input_line, sizeof input_line, vin);
	printf("%s", input_line);

	while (fgets(input_line, sizeof input_line, vin) != NULL)
	{
		printf("%s", input_line);
	}
}



-- 
    Peter Mroz                    |    E.I. Du Pont de Nemours & Co.
    eplrx7!mroz at uunet.uu.net      |    Consultant, Scicon
    mrozpa%wmvx at dupont.com        |    DuPont Building, D4078
                                  |    Wilmington, DE 19898
--
The UUCP Mailer



More information about the Comp.unix.aix mailing list