summaryrefslogtreecommitdiff
path: root/executors/shell/executor_shell.go
diff options
context:
space:
mode:
Diffstat (limited to 'executors/shell/executor_shell.go')
-rw-r--r--executors/shell/executor_shell.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/executors/shell/executor_shell.go b/executors/shell/executor_shell.go
index 236cd660..2103fbd6 100644
--- a/executors/shell/executor_shell.go
+++ b/executors/shell/executor_shell.go
@@ -17,6 +17,7 @@ import (
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/executors"
"gitlab.com/gitlab-org/gitlab-runner/helpers"
+ "gitlab.com/gitlab-org/gitlab-runner/helpers/featureflags"
)
type executor struct {
@@ -59,7 +60,7 @@ func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
func (s *executor) killAndWait(cmd *exec.Cmd, waitCh chan error) error {
for {
s.Debugln("Aborting command...")
- helpers.KillProcessGroup(cmd)
+ s.killProcessGroup(cmd)
select {
case <-time.After(time.Second):
case err := <-waitCh:
@@ -68,6 +69,15 @@ func (s *executor) killAndWait(cmd *exec.Cmd, waitCh chan error) error {
}
}
+func (s *executor) killProcessGroup(cmd *exec.Cmd) {
+ if s.Build.IsFeatureFlagOn(featureflags.UseLegacyUnixProcessKillSignal) {
+ helpers.LegacyKillProcessGroup(cmd)
+ return
+ }
+
+ helpers.KillProcessGroup(cmd)
+}
+
func (s *executor) Run(cmd common.ExecutorCommand) error {
// Create execution command
c := exec.Command(s.BuildShell.Command, s.BuildShell.Arguments...)
@@ -76,7 +86,7 @@ func (s *executor) Run(cmd common.ExecutorCommand) error {
}
helpers.SetProcessGroup(c)
- defer helpers.KillProcessGroup(c)
+ defer s.killProcessGroup(c)
// Fill process environment variables
c.Env = append(os.Environ(), s.BuildShell.Environment...)