Menu

#36 Console I/O stalls

closed
DV
NppExec (13)
5
2008-02-06
2008-01-30
No

While the new console I/O buffering scheme for NppExec is much faster, it has a shortcoming when dealing with small status updates of I/O before completion of the launched external program.

I have a utility that takes about a minute to execute, and outputs short lines of progress text along the way. I think it is because the buffer size limit is not reached that the progress text does not appear until the external application terminates. It would be good to have a periodic timer that will flush the I/O buffer every 500ms or so in order to handle situations like this.

BTW, thanks DV for a great plugin!

Discussion

  • DV

    DV - 2008-02-06

    Logged In: YES
    user_id=1468738
    Originator: NO

    This is an application-specific behaviour. For example, this AWK script:

    BEGIN {
    for (j = 0; j < 100; j++) {
    timeout()

    printf( "\b\b%02d", j )

    timeout()
    }
    }

    function timeout() {
    for (i = 0; i < 100000; i++) {
    sin(i*3.14 + 0.0319319)
    }
    }

    shows the same behaviour as you described.
    But the following AWK script, which is almost the same as previous, prints the progress correctly:

    BEGIN {
    for (j = 0; j < 100; j++) {
    timeout()

    printf( "\b\b%02d", j )
    fflush()

    timeout()
    }
    }

    function timeout() {
    for (i = 0; i < 100000; i++) {
    sin(i*3.14 + 0.0319319)
    }
    }

    The only difference - fflush() - forces AWK to write the output string immediately. Whereas the printf() function alone does not guarantee immediate appearance of the output string in the pipe.

     
  • Greg Williams

    Greg Williams - 2008-02-06
    • status: open --> closed
     
  • Greg Williams

    Greg Williams - 2008-02-06

    Logged In: YES
    user_id=1970571
    Originator: YES

    This is true. I created a Ruby script that flushes I/O before and after some sleeps, and I see the proper behavior. The place where we're seeing the errant behavior in in a Windows C++ console application.

     

Log in to post a comment.