Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed build and SIGINT race condition and massive sleep after SIGINT #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions runner/engine.go
Expand Up @@ -416,7 +416,12 @@ func (e *Engine) runBin() error {
default:
}
}()

<-e.binStopCh
e.withLock(func() {
e.binRunning = false
})

e.mainDebug("trying to kill pid %d, cmd %+v", cmd.Process.Pid, cmd.Args)
defer func() {
stdout.Close()
Expand All @@ -431,9 +436,6 @@ func (e *Engine) runBin() error {
} else {
e.mainDebug("cmd killed, pid: %d", pid)
}
e.withLock(func() {
e.binRunning = false
})
cmdBinPath := cmdPath(e.config.rel(e.config.binPath()))
if _, err = os.Stat(cmdBinPath); os.IsNotExist(err) {
return
Expand Down
4 changes: 3 additions & 1 deletion runner/util_darwin.go
Expand Up @@ -17,10 +17,12 @@ func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) {
if err = syscall.Kill(-pid, syscall.SIGINT); err != nil {
return
}
time.Sleep(e.config.Build.KillDelay * time.Millisecond)
time.Sleep(e.config.Build.KillDelay)
}

// https://stackoverflow.com/questions/22470193/why-wont-go-kill-a-child-process-correctly
err = syscall.Kill(-pid, syscall.SIGKILL)

// Wait releases any resources associated with the Process.
_, _ = cmd.Process.Wait()
return pid, err
Expand Down
4 changes: 2 additions & 2 deletions runner/util_linux.go
Expand Up @@ -17,15 +17,15 @@ func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) {
if err = syscall.Kill(-pid, syscall.SIGINT); err != nil {
return
}
time.Sleep(e.config.Build.KillDelay * time.Millisecond)
time.Sleep(e.config.Build.KillDelay)
}

// https://stackoverflow.com/questions/22470193/why-wont-go-kill-a-child-process-correctly
err = syscall.Kill(-pid, syscall.SIGKILL)

// Wait releases any resources associated with the Process.
_, _ = cmd.Process.Wait()
return
return pid, err
}

func (e *Engine) startCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) {
Expand Down