Kill the blame back-end on window close.
Currently 'git-gui blame' does not kill its back-end process, hoping that it will die anyway when the pipe is closed. However, in some cases the process works for a long time without producing any output. This behavior results in a runaway CPU hog. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Alexander Gavrilov committed
Jul 17, 2008 at 00:48 UTC
e6131d30c21d2c308571078729dc8d2e1b746285
2 files changed
+26
-4
git-gui.sh
+14
@@ -497,6 +497,20 @@ proc githook_read {hook_name args} {
497
return {}
498
}
499
500
+proc kill_file_process {fd} {
501
+ set process [pid $fd]
502
+
503
+ catch {
504
+ if {[is_Windows]} {
505
+ # Use a Cygwin-specific flag to allow killing
506
+ # native Windows processes
507
+ exec kill -f $process
508
+ } else {
509
+ exec kill $process
510
+ }
511
+ }
512
+}
513
+
514
proc sq {value} {
515
regsub -all ' $value "'\\''" value
516
return "'$value'"
lib/blame.tcl
+12
-4
@@ -326,19 +326,27 @@ constructor new {i_commit i_path} {
326
bind $w.file_pane <Configure> \
327
"if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
328
329
+ wm protocol $top WM_DELETE_WINDOW "destroy $top"
330
+ bind $top <Destroy> [cb _kill]
331
+
332
_load $this {}
333
}
334
335
+method _kill {} {
336
+ if {$current_fd ne {}} {
337
+ kill_file_process $current_fd
338
+ catch {close $current_fd}
339
+ set current_fd {}
340
+ }
341
+}
342
+
343
method _load {jump} {
344
variable group_colors
345
346
_hide_tooltip $this
347
348
if {$total_lines != 0 || $current_fd ne {}} {
338
- if {$current_fd ne {}} {
339
- catch {close $current_fd}
340
- set current_fd {}
341
- }
349
+ _kill $this
350
351
foreach i $w_columns {
352
$i conf -state normal