From 3276c8ff6c1c574e27183351bac83685d01f043a Mon Sep 17 00:00:00 2001 From: Grzegorz Marszalek Date: Tue, 5 Mar 2024 23:50:06 +0100 Subject: [PATCH 1/2] add no_pty conifg option to fix #533 --- runner/config.go | 1 + runner/util_linux.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/runner/config.go b/runner/config.go index a5af959c..a6b8ed91 100644 --- a/runner/config.go +++ b/runner/config.go @@ -94,6 +94,7 @@ type cfgMisc struct { type cfgScreen struct { ClearOnRebuild bool `toml:"clear_on_rebuild"` KeepScroll bool `toml:"keep_scroll"` + NoPTY bool `toml:"no_pty"` } type sliceTransformer struct{} diff --git a/runner/util_linux.go b/runner/util_linux.go index 658671b3..d28759bf 100644 --- a/runner/util_linux.go +++ b/runner/util_linux.go @@ -30,6 +30,21 @@ func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) { func (e *Engine) startCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) { c := exec.Command("/bin/sh", "-c", cmd) + if e.config.Screen.NoPTY { + stderr, err := c.StderrPipe() + if err != nil { + return nil, nil, nil, err + } + stdout, err := c.StdoutPipe() + if err != nil { + return nil, nil, nil, err + } + err = c.Start() + if err != nil { + return nil, nil, nil, err + } + return c, stdout, stderr, err + } f, err := pty.Start(c) return c, f, f, err } From c06f7f763984f97fd9cc3da2921b775127b40163 Mon Sep 17 00:00:00 2001 From: Grzegorz Marszalek Date: Wed, 6 Mar 2024 00:16:47 +0100 Subject: [PATCH 2/2] fix process kill --- runner/util_linux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runner/util_linux.go b/runner/util_linux.go index d28759bf..c9b69fb3 100644 --- a/runner/util_linux.go +++ b/runner/util_linux.go @@ -31,6 +31,9 @@ func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) { func (e *Engine) startCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) { c := exec.Command("/bin/sh", "-c", cmd) if e.config.Screen.NoPTY { + c.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, + } stderr, err := c.StderrPipe() if err != nil { return nil, nil, nil, err