Skip to content

Commit e2f90ee

Browse files
angavrilovpaulusmack
authored andcommitted
gitk: Kill back-end processes on window close
When collecting commits for a rarely changed, or recently created file or directory, rev-list may work for a noticeable period of time without producing any output. Such processes don't receive SIGPIPE for a while after gitk is closed, thus becoming runaway CPU hogs. Signed-off-by: Alexander Gavrilov <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent c11ff12 commit e2f90ee

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

gitk

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,33 @@ proc start_rev_list {view} {
375375
return 1
376376
}
377377

378+
proc stop_instance {inst} {
379+
global commfd leftover
380+
381+
set fd $commfd($inst)
382+
catch {
383+
set pid [pid $fd]
384+
exec kill $pid
385+
}
386+
catch {close $fd}
387+
nukefile $fd
388+
unset commfd($inst)
389+
unset leftover($inst)
390+
}
391+
392+
proc stop_backends {} {
393+
global commfd
394+
395+
foreach inst [array names commfd] {
396+
stop_instance $inst
397+
}
398+
}
399+
378400
proc stop_rev_list {view} {
379-
global commfd viewinstances leftover
401+
global viewinstances
380402

381403
foreach inst $viewinstances($view) {
382-
set fd $commfd($inst)
383-
catch {
384-
set pid [pid $fd]
385-
exec kill $pid
386-
}
387-
catch {close $fd}
388-
nukefile $fd
389-
unset commfd($inst)
390-
unset leftover($inst)
404+
stop_instance $inst
391405
}
392406
set viewinstances($view) {}
393407
}
@@ -2103,6 +2117,7 @@ proc makewindow {} {
21032117
bind . <$M1B-minus> {incrfont -1}
21042118
bind . <$M1B-KP_Subtract> {incrfont -1}
21052119
wm protocol . WM_DELETE_WINDOW doquit
2120+
bind . <Destroy> {stop_backends}
21062121
bind . <Button-1> "click %W"
21072122
bind $fstring <Key-Return> {dofind 1 1}
21082123
bind $sha1entry <Key-Return> gotocommit

0 commit comments

Comments
 (0)