KDBG - debugger not printing value

Using this function as part of the larger scanvirusbin code. If step I through the debugger, it will not print the value noted in the console window.

When I run the command line, it displays and erases the counter. However, it skips numbers. I need to find out if it’s working and the print buffer can’t keep up.

Command

Scan_Results_Filter("clamscan -r --follow-dir-symlinks=2 --follow-file-symlinks=2 --cross-fs=no /bin");
void Scan_Results_Filter(const char* cmd)
{
     int filecounter;    
     int delete_line_flag;
     int scan_results_flag;

     FILE *FilePtr;
     #define LineSize 1024+1
     char cmdout[LineSize];

     filecounter = 0;    
     delete_line_flag= false;
     scan_results_flag= false;
     
     char ch;

 //noecho();
    //cbreak();    /* Line buffering disabled. pass on everything */


     if ((FilePtr = popen(cmd, "r")) == NULL)
          printf("clamscan: error opening pipe!
");
          else
          {
               while (fgets(cmdout, LineSize, FilePtr) != NULL)
               {
                    if (delete_line_flag == true)  //break point
                    {
                         printf("\e2K\r");
                         delete_line_flag= false;
                    }

                    //if scan summary then stop deleting lines
                    if (strstr(cmdout,"----------- SCAN SUMMARY -----------"))
                    {          
                         //printf("filecount= %d
", filecounter);
                         scan_results_flag= true;
                    }

                    if (scan_results_flag == true)
                    {
                         printf("%s", cmdout);
                         continue;
                    }
                    else if (strstr(cmdout,": Symbolic"))
                         printf("%s
", cmdout);
                    else if (strstr(cmdout,": FOUND"))
                    {
                         filecounter++;
                         printf("%s
", cmdout);
                    }     
                    else if (strstr(cmdout,": MOVED TO"))
                         printf("%s
", cmdout);
                    else if ( (strstr(cmdout,": OK")) || (strstr(cmdout,": EMPTY")) )
                    {
                         filecounter++;
                         if ((filecounter % 1) == 0)
                         {
                              printf("%d", filecounter);  //no print
                              delete_line_flag= true;
                              //ch= getch();
                         }
                   }
               }

               if(pclose(FilePtr))
                    printf("clamscan: error closing pipe
");
          }
}


#kdbg

load source code → opensource code → run → step into (repeat)

Changing the printf statement still will not output text.

printf("%s", "filecounter");

If I add a ’
', it will print the line. ??

output to terminal is line buffered by default. See “man stdio” and related manuals.

printf("%d", filecounter);  fflush(stdout);

I was able to test scanvirus. Scan_Results_Filter now works. Now, I need create a string array of the filter names and use them to use mask folder names. Then, change the string as needed before it’s called.

Thanks for the help…