code.gitea.io/gitea@v1.19.3/modules/process/manager_unix.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  //go:build !windows
     5  
     6  package process
     7  
     8  import (
     9  	"os/exec"
    10  	"syscall"
    11  )
    12  
    13  // SetSysProcAttribute sets the common SysProcAttrs for commands
    14  func SetSysProcAttribute(cmd *exec.Cmd) {
    15  	// When Gitea runs SubProcessA -> SubProcessB and SubProcessA gets killed by context timeout, use setpgid to make sure the sub processes can be reaped instead of leaving defunct(zombie) processes.
    16  	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
    17  }