You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
os.Process.Kill() only kill the parent process, not including the child processes.
The following is the code for fix:
jobTimeout:=args.Config["timeout"]
varjt time.DurationifjobTimeout!="" {
jt, err=time.ParseDuration(jobTimeout)
iferr!=nil {
returnnil, errors.New("shell: Error parsing job timeout")
}
cmd.SysProcAttr=&syscall.SysProcAttr{Setpgid: true}
}
log.Printf("shell: going to run %s", command)
err=cmd.Start()
iferr!=nil {
returnnil, err
}
varjobTimeoutMessagestringvarjobTimedOutboolifjt!=0 {
slowTimer:=time.AfterFunc(jt, func() {
// Kill child process to avoid cmd.Wait()err:=syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL) // note the minus signiferr!=nil {
jobTimeoutMessage=fmt.Sprintf("shell: Job '%s' execution time exceeding defined timeout %v. SIGKILL returned error. Job may not have been killed", command, jt)
} else {
jobTimeoutMessage=fmt.Sprintf("shell: Job '%s' execution time exceeding defined timeout %v. Job was killed", command, jt)
}
jobTimedOut=truereturn
})
deferslowTimer.Stop()
}
cobolbaby
changed the title
No retry mechanism after cmd.Process.Kill() fails, causing the task to remain running.cmd.Process.Kill() does not clean up the started process, causing the job to remain running.
Sep 24, 2023
Describe the bug
A clear and concise description of what the bug is.
https://github.com/distribworks/dkron/blob/master/builtin/bins/dkron-executor-shell/shell.go#L119C1-L124
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Init State:
After cmd.Process.Kill()
Specifications:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: