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

Fix SIGURG Handling #5233

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/app/starter/master_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func Master(rpcSocket, masterSocket int, containerPid int, e *engine.Engine) {
// we could receive signal from child with CreateContainer call so we
// set the signal handler earlier to queue signals until MonitorContainer
// is called to handle them
signals := make(chan os.Signal, 1)
// Use a channel size of two here, since we may receive SIGURG, which is
// used for non-cooperative goroutine preemption starting with Go 1.14.
signals := make(chan os.Signal, 2)
signal.Notify(signals)

ctx := context.TODO()
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/runtime/engine/fakeroot/engine_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ func (e *EngineOperations) MonitorContainer(pid int, signals chan os.Signal) (sy
continue
}
return status, nil
case syscall.SIGURG:
// Ignore SIGURG, which is used for non-cooperative goroutine
// preemption starting with Go 1.14. For more information, see
// https://github.com/golang/go/issues/24543.
break
default:
if err := syscall.Kill(pid, s.(syscall.Signal)); err != nil {
return status, fmt.Errorf("interrupted by signal %s", s.String())
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/runtime/engine/oci/monitor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (e *EngineOperations) MonitorContainer(pid int, signals chan os.Signal) (sy
continue
}
return status, nil
case syscall.SIGURG:
// Ignore SIGURG, which is used for non-cooperative goroutine
// preemption starting with Go 1.14. For more information, see
// https://github.com/golang/go/issues/24543.
break
default:
if err := syscall.Kill(pid, s.(syscall.Signal)); err != nil {
return status, fmt.Errorf("interrupted by signal %s", s.String())
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/runtime/engine/singularity/monitor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (e *EngineOperations) MonitorContainer(pid int, signals chan os.Signal) (sy
continue
}
return status, nil
case syscall.SIGURG:
// Ignore SIGURG, which is used for non-cooperative goroutine
// preemption starting with Go 1.14. For more information, see
// https://github.com/golang/go/issues/24543.
break
default:
if e.EngineConfig.GetSignalPropagation() {
if err := syscall.Kill(pid, s.(syscall.Signal)); err != nil {
Expand Down
9 changes: 8 additions & 1 deletion internal/pkg/runtime/engine/singularity/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const defaultShell = "/bin/sh"
func (e *EngineOperations) StartProcess(masterConn net.Conn) error {
// Manage all signals.
// Queue them until they're ready to be handled below.
signals := make(chan os.Signal, 1)
// Use a channel size of two here, since we may receive SIGURG, which is
// used for non-cooperative goroutine preemption starting with Go 1.14.
signals := make(chan os.Signal, 2)
signal.Notify(signals)

if err := e.runFuseDrivers(true, -1); err != nil {
Expand Down Expand Up @@ -244,6 +246,11 @@ func (e *EngineOperations) StartProcess(masterConn net.Conn) error {
statusChan <- status
}
}
case syscall.SIGURG:
// Ignore SIGURG, which is used for non-cooperative goroutine
// preemption starting with Go 1.14. For more information, see
// https://github.com/golang/go/issues/24543.
break
default:
signal := s.(syscall.Signal)
// EPERM and EINVAL are deliberately ignored because they can't be
Expand Down