fflush & curses

Jeffrey Gleixner glex at uh.msc.umn.edu
Tue Jan 9 15:53:05 AEST 1990


	I wrote a C program using Curses that calls the following 

**str is "grep -l a_string `find Some_home_dir -type f -print`"  **

void  init_find_win(str)
char  *str;
/*
 *      makes a window showing the files that are found
 */
{
        FILE    *pipe;
        char    buf[BUFSIZ];
        int     i=0,j;

        buf[0]=NULL;
        if((pipe = popen(str, "r")) == NULL) {
                perror("init_find_win: popen");
                exit(0);
        }

        while ((fgets(buf, 40, pipe) != NULL) && i<19) {
                mvwprintw(f_win, ++i, 0, "* %-45s", buf);
                mvwprintw(f_win, i, 44, "*");
        }
        mvwprintw(f_win, i++,0, ">> Control-w - pulls up this window.      <<");

	... the rest deleted....
}

	This works fine except it seems to "miss" a few files.  i.e. if
	I execute the same grep... command in the correct directory it
	finds more files with the string.  I thought that the output from	
	the pipe wasn't being flushed to the window, so I tried
	fflush (stdout) , fflush (f_win), fflush (pipe) but nothing seems
	to print all of the files to the window.  It does search through all
	of the files ( if I look for an 'e' it prints out a 19 files).

	This is really strange. %-(
	
thanks in advance.
Please try E-mail first 
glex at msc.umn.edu



More information about the Comp.lang.c mailing list