This is one of the Code walkthrough I wrote while exploring the Gitea codebase.
The Go exec package runs external commands and is improved by the Gitea modules/process package.
The list of processes can be obtained in a thread safe manner, to be displayed or to cancel a particular process.
The Gitea modules/git has an interface similar to Gitea modules/process (Run instead of Exec, RunInDir instead of ExecDir etc.) and:
It does not share code with Gitea modules/process except for the process manager.