quickjs icon indicating copy to clipboard operation
quickjs copied to clipboard

[repl] Cannot interrupt executions with Ctrl-C on Windows

Open absop opened this issue 1 year ago • 0 comments

The Ctrl-C shortcut does not send a SIGINT signal.

From the Windows console document:

The CTRL+C and CTRL+BREAK key combinations receive special handling by console processes. By default, when a console window has the keyboard focus, CTRL+C or CTRL+BREAK is treated as a signal (SIGINT or SIGBREAK) and not as keyboard input.

But in the repl of QuickJS, on Windows, press CTRL+C does not send a SIGINT signal to interrupt the execution of time-consuming commands.

Screenshot on Windows

image

Screenshot on Linux

image

The code:

function mod7(limit) {
    var count = 0;
    for (var i = 0; i < limit; i++)
        if (i % 7 === 0)
            count++;
    return count;
}

function test_mod7() {
    var s, r, e;
    s = Date.now();
    r = mod7(1000000000);
    e = Date.now();
    console.log((e - s) / 1000, r);
}

test_mod7();

absop avatar Jan 21 '24 14:01 absop