@matheusbsbs / matheus-bagliano / commits / e2f90ee45c
Fork 0

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 <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Jul 12, 2008 at 16:09 UTC e2f90ee45c8b2d13a6c6b8a9f4bc3dce05408c99
1 file changed +25 -10
gitk
+25 -10
@@ -375,19 +375,33 @@ proc start_rev_list {view} {
375 return 1
376 }
377
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 +
400 proc stop_rev_list {view} {
379 - global commfd viewinstances leftover
401 + global viewinstances
402
403 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
405 }
406 set viewinstances($view) {}
407 }
@@ -2103,6 +2117,7 @@ proc makewindow {} {
2117 bind . <$M1B-minus> {incrfont -1}
2118 bind . <$M1B-KP_Subtract> {incrfont -1}
2119 wm protocol . WM_DELETE_WINDOW doquit
2120 + bind . <Destroy> {stop_backends}
2121 bind . <Button-1> "click %W"
2122 bind $fstring <Key-Return> {dofind 1 1}
2123 bind $sha1entry <Key-Return> gotocommit