mirror of
https://github.com/containers/skopeo.git
synced 2025-09-09 10:39:30 +00:00
tests: Add new "procutils" that exposes PDEATHSIG
To fix compilation on MacOS. I think actually we want to use this pervasively in our tests on Linux; it doesn't really matter when run inside a transient container, but `PDEATHSIG` is useful for persistent containers (e.g.) toolbox and when running outside of a pid namespace, e.g. on a host system shell directly or in systemd. Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
12
integration/procutils.go
Normal file
12
integration/procutils.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLifecycleToParentIfPossible tries to exit if the parent process exits (only works on Linux)
|
||||||
|
func cmdLifecycleToParentIfPossible(c *exec.Cmd) {
|
||||||
|
}
|
14
integration/procutils_linux.go
Normal file
14
integration/procutils_linux.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLifecyleToParentIfPossible is a thin wrapper around prctl(PR_SET_PDEATHSIG)
|
||||||
|
// on Linux.
|
||||||
|
func cmdLifecycleToParentIfPossible(c *exec.Cmd) {
|
||||||
|
c.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Pdeathsig: syscall.SIGTERM,
|
||||||
|
}
|
||||||
|
}
|
@@ -186,9 +186,7 @@ func newProxy() (*proxy, error) {
|
|||||||
// Note ExtraFiles starts at 3
|
// Note ExtraFiles starts at 3
|
||||||
proc := exec.Command("skopeo", "experimental-image-proxy", "--sockfd", "3")
|
proc := exec.Command("skopeo", "experimental-image-proxy", "--sockfd", "3")
|
||||||
proc.Stderr = os.Stderr
|
proc.Stderr = os.Stderr
|
||||||
proc.SysProcAttr = &syscall.SysProcAttr{
|
cmdLifecycleToParentIfPossible(proc)
|
||||||
Pdeathsig: syscall.SIGTERM,
|
|
||||||
}
|
|
||||||
proc.ExtraFiles = append(proc.ExtraFiles, theirfd)
|
proc.ExtraFiles = append(proc.ExtraFiles, theirfd)
|
||||||
|
|
||||||
if err = proc.Start(); err != nil {
|
if err = proc.Start(); err != nil {
|
||||||
|
Reference in New Issue
Block a user