v0.48.1 deaab59

python_proc_unix.go RawHistoryFolder

1//go:build !windows
2
3package tools
4
5import (
6	"io"
7	"os/exec"
8	"sync"
9	"syscall"
10	"time"
11)
12
13// pythonProcessWaitDelay bounds process cleanup beyond the invocation or
14// probe deadline. Bounded return is required; absolute containment of every
15// detached descendant is not promised.
16const pythonProcessWaitDelay = 5 * time.Second
17
18// configurePythonProcess makes context cancellation terminate the Python
19// process group and closes the output pipe exactly once. It mirrors the
20// Bash Unix mechanics without touching Bash behavior. When cancelErr is
21// non-nil, the termination error from the Cancel callback is recorded
22// there (guarded by its mutex): Wait folds that error into its own
23// process error, so without this capture the cleanup detail is
24// unreachable and a partial kill cannot report surviving descendants.
25func configurePythonProcess(cmd *exec.Cmd, output io.Closer, cancelErr *pythonCancelError) func() {
26	if cmd != nil {
27		cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
28		cmd.WaitDelay = pythonProcessWaitDelay
29	}
30	var closeOutput sync.Once
31	closePipe := func() {
32		closeOutput.Do(func() {
33			if output != nil {
34				_ = output.Close()
35			}
36		})
37	}
38	if cmd != nil {
39		cmd.Cancel = func() error {
40			closePipe()
41			err := killPythonProcessGroup(cmd)
42			if cancelErr != nil {
43				cancelErr.set(err)
44			}
45			return err
46		}
47	}
48	return closePipe
49}
50
51// killPythonProcessGroup forcefully terminates the process group so
52// descendants cannot retain the output pipe indefinitely.
53func killPythonProcessGroup(cmd *exec.Cmd) error {
54	if cmd == nil || cmd.Process == nil {
55		return nil
56	}
57	pgid := cmd.Process.Pid
58	if err := syscall.Kill(-pgid, syscall.SIGKILL); err == syscall.ESRCH {
59		return nil
60	} else {
61		return err
62	}
63}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close