Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!wuarchive!udel!eplrx7!mroz From: mroz@eplrx7.uucp (Peter Mroz) Newsgroups: comp.unix.aix Subject: Problems with popen on RS/6000 Keywords: popen, C, vmstat Message-ID: <1990Aug15.203239.8832@eplrx7.uucp> Date: 15 Aug 90 20:32:39 GMT Sender: usenet@ee.udel.edu Organization: DuPont Engineering Physics Lab Lines: 56 Nntp-Posting-Host: louie.udel.edu 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 #include 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@uunet.uu.net | Consultant, Scicon mrozpa%wmvx@dupont.com | DuPont Building, D4078 | Wilmington, DE 19898 -- The UUCP Mailer