mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #477] ^C fails to immediately abort indexing #209
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @quantatic on GitHub (Mar 14, 2025).
Original GitHub issue: https://github.com/bootandy/dust/issues/477
This is an issue very similar to https://github.com/bootandy/dust/issues/367, though I'm opening a separate issue because the issue manifests in a slightly different way.
Expected Behavior
When I send a SIGINT signal to a running
dustprocess (viakillorC-c), I expect the process to quit immedietly.Actual Behavior
When indexing a large directory, or indexing on a slow filesystem, attempting to interrupt the process causes
dustto continue processing, sometimes for a long period of time. I am able to kill it via SIGKILL, though intuitively, I might prefer it to handle aC-cin a way that immediately kills the process.Example Reproduction
In this reproduction, I attempt to exit the running process with
C-cseveral times, which lets me know that the process is "Aborting", but continues running. Finally, I kill the process withkill -9 <PID>, at which point the process exits.Investigation
I am able to consistently reproduce this issue on the most recent commit as of the posting of this issue:
dd799706fbd062b468d5e8e219c0ef332344588b.It seems that the SIGINT handler configured attempts to perform a graceful shutdown when indexing is in process, choosing to set
error_listen_for_ctrlc.abortrather than immediately exiting.This flag is checked during directory walking, but only at the very beginning of a walk for a directory -- if a walk for a large directory (or a directory on a very slow filesystem) is already in progress, it will wait until the walk completes, which may take a significant period of time.
Suggestions
I'm not entirely certain why we set
error_listen_for_ctrlc.abortwhen we receive SIGINT, rather than simply exiting the process immediately. Unless there's some behavior I'm not aware of we're attempting to handle, it seems to me that we could rewrite this function as follows:When running with this patch applied, I get the behavior I expect -- namely, an exit as soon as SIGINT is received:
If we do want to handle SIGINT gracefully for some reason I'm not aware of, I might suggest some sort of flag that forcefully exits the process on the second SIGINT, while displaying a message during the first that we are attempting to shut down gracefully and to press
C-cfor immediate abort (like the following, approximately):Alternatively, some sort of command-line option that immediately aborts rather than attempting to finalize indexing may be a viable option.
I'm happy to put out a PR for any of these changes (though in my personal opinion, the first approach -- immediate exit -- meshes best with how I would naively expect the program to behave).
Thanks for the great tool! I've gotten a lot of great usage out of it 😄
@bootandy commented on GitHub (Mar 15, 2025):
Honestly, I was simply trying to do a clean shutdown.
I was aware that if it scanned a large directory it would take a while to exit but didn't think it would be a problem. If its an issue we can fix it.
I'm trying to remember why I didn't do that in the first place ..... and I can't. I think it just felt cleaner at the time.
In summary: I think - Yes we'll try your simple patch, if you want to make a PR I'll accept. As you say I think the first approach is probably best - if there are problems with that we'll figure that out later.
@bootandy commented on GitHub (Mar 15, 2025):
Also I'm on vacation next week (ski!). So I'm going to go quite for at least a week.
Thanks,