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
Disable SIGINT context cancelling on Linux #670
Comments
I am interested in this as well, as I'd like to gracefully handle SIGINT/SIGTERM in my harness program, but I can't right now because it squashes the browsers managed by chromedp. There's a simple patch that could be applied in diff --git a/allocate.go b/allocate.go
index 5920cff..bd128d1 100644
--- a/allocate.go
+++ b/allocate.go
@@ -12,6 +12,7 @@ import (
"os/exec"
"path/filepath"
"sync"
+ "syscall"
"time"
)
@@ -181,6 +182,10 @@ func (a *ExecAllocator) Allocate(ctx context.Context, opts ...BrowserOption) (*B
cmd.Env = append(os.Environ(), a.initEnv...)
}
+ cmd.SysProcAttr = &syscall.SysProcAttr{
+ Setpgid: true,
+ }
+
// We must start the cmd before calling cmd.Wait, as otherwise the two
// can run into a data race.
if err := cmd.Start(); err != nil { However, I'm not sure they will want to apply this, because it also has the effect of causing browsers to remain open after a typical harness is closed with SIGTERM/SIGINT, which might be a problem for some other users. @mvdan -- Would you be open to a pull request for an ExecAllocatorOption that allows for adding the browser to the process group of the parent process in this way? If not, any thoughts on other ways to handle this situation? |
I think we could expose an ExecAllocatorOption that would take a function to modify an And yeah, a PR would be welcome. |
#674 has been merged. Closing this issue. |
My code is a pipeline with several workerpools. One of them is controlling headless chrome via chromedp. On windows code work flawless (i added manual graceful shutdown), on linux i just got context canceled on all pending tasks to browser.
Is there any way to disable force-kiliing Chrome process without using RemoteAllocator? I tried to comment allocateCmdOptions in allocate_linux with no luck.
UPD: checked kill command (sigterm) work just fine, but ctrl+c is not.
The text was updated successfully, but these errors were encountered: