cli-progress icon indicating copy to clipboard operation
cli-progress copied to clipboard

Process interrupt ignored when using cli-progress v3.11

Open wmelton opened this issue 3 years ago • 7 comments

When using cli-progress, if you attempt to interrupt the process using ctrl+c the command is ignored until the process fully completes.

Reading through the readme I may have missed how this is supposed to be handled, but I do not see any config options to specify how to handle a kill request from a user.

wmelton avatar Jun 09 '22 13:06 wmelton

an option called gracefulExit has been added to v3.11 (see https://github.com/npkgz/cli-progress/blob/master/CHANGES.md) which restores the terminal state on SIGINT/SIGTERM

AndiDittrich avatar Jun 09 '22 14:06 AndiDittrich

an option called gracefulExit has been added to v3.11 (see https://github.com/npkgz/cli-progress/blob/master/CHANGES.md) which restores the terminal state on SIGINT/SIGTERM

even using this option I still face the same behaviour

hfabio avatar Jun 09 '22 15:06 hfabio

set gracefulExit: false to restore the "old" behaviour. i've to check the node.js docs regarding the SIGINT listener

AndiDittrich avatar Jun 09 '22 18:06 AndiDittrich

from the docs

'SIGTERM' and 'SIGINT' have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior will be removed (Node.js will no longer exit).

i wasn't aware of this side effect. sry!

the question is how to solve this (putting and process.exit on the end of the listener may avoids users to add their own actions..)

AndiDittrich avatar Jun 09 '22 19:06 AndiDittrich

This is a great library! The ability to hard stop a script from cli is essential though.

wmelton avatar Jun 23 '22 21:06 wmelton

set gracefulExit: false - this will be the default value in the upcoming hotfix

AndiDittrich avatar Jun 24 '22 16:06 AndiDittrich

I use cli-progress 3.12.0 I tried:

const bar1 = new cliProgress.SingleBar({gracefulExit: true}, cliProgress.Presets.shades_classic);

and

const bar1 = new cliProgress.SingleBar({gracefulExit: false}, cliProgress.Presets.shades_classic);

both don't kill the node process after hitting ctrl+c in bash (the progress continues to run and the node process continues to work).

ivanakcheurov avatar Oct 14 '23 08:10 ivanakcheurov