dool icon indicating copy to clipboard operation
dool copied to clipboard

Add SIGINT/SIGTERM/SIGHUP/SIGBREAK handler to fix missing data issue in --output mode

Open minghungchen opened this issue 4 years ago • 2 comments

ISSUE TYPE
  • Bugfix pull-request
DSTAT VERSION
0.9.10
SUMMARY

Add a SIGINT and SIGTERM handler so the data still in the I/O buffer will be written out before exiting the program.

minghungchen avatar Jul 19 '21 14:07 minghungchen

:+1:

An orthogonal way of doing this is to disable buffering on the file (which might not be efficient for high frequency stats gathering). which is the purpose of https://github.com/scottchiefbaker/dool/pull/12

@minghungchen I'd like to see SIGHUP signal being catched as well, what do you think ?

msimonin avatar Jul 20 '21 08:07 msimonin

@msimonin Sure. SIGHUP in Linux and SIGBREAK in Windows can be caught now

minghungchen avatar Jul 20 '21 13:07 minghungchen

Apologies... Github was not sending me alerts for issues and pull requests on this repo. I did not see this until just now.

Is this still relevant? I'm working through some backlog.

scottchiefbaker avatar Jun 03 '23 02:06 scottchiefbaker

I just landed some code that dramatically improves --output and I think addresses this issue. Please check https://github.com/scottchiefbaker/dool/commit/82cf041ba30333da3b73af0d60ea055802ca5779 and let me know. There is a pre-release v1.2.0 available with this code in it.

scottchiefbaker avatar Jun 05 '23 17:06 scottchiefbaker

I think I've already fixed most of the stuff related to --output but I want to implement signal handling in the future so this is a good start.

scottchiefbaker avatar Jun 05 '23 18:06 scottchiefbaker

@minghungchen is it possible to use signal handling to not output the trailing "^C" on STDOUT if I press CTRL + C to terminate dool?

scottchiefbaker avatar Jun 05 '23 18:06 scottchiefbaker

A simple trick is print out a few '\b' and then print something else to overwrite the existing contents, e.g., a few space to overwrite ^c. I did not test in dool but this trick usually works, but might need a flush at the end.

minghungchen avatar Jun 06 '23 14:06 minghungchen

@minghungchen oh good call. I just landed eee27c5 which seems to work for covering up "^C"

scottchiefbaker avatar Jun 06 '23 23:06 scottchiefbaker