summaryrefslogtreecommitdiff
path: root/cmd/podman/sigproxy.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-03-16 10:34:32 -0400
committerGitHub <noreply@github.com>2018-03-16 10:34:32 -0400
commitd7acfb478e5e5e6ac344d18c1a65ab81996fd8b2 (patch)
treec1a335e5a2291e8447e8f9f4c4ef02e7cde2fd0c /cmd/podman/sigproxy.go
parent2f533888a5adcbfb57ec22a8086aa5e76acb9071 (diff)
parentcd73a6904d3dc91f305c7415ab7bada8a976d815 (diff)
downloadpodman-d7acfb478e5e5e6ac344d18c1a65ab81996fd8b2.tar.gz
podman-d7acfb478e5e5e6ac344d18c1a65ab81996fd8b2.tar.bz2
podman-d7acfb478e5e5e6ac344d18c1a65ab81996fd8b2.zip
Merge pull request #447 from mheon/sig_proxy
Add signal proxying to podman run and attach
Diffstat (limited to 'cmd/podman/sigproxy.go')
-rw-r--r--cmd/podman/sigproxy.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmd/podman/sigproxy.go b/cmd/podman/sigproxy.go
new file mode 100644
index 000000000..fd1415dc6
--- /dev/null
+++ b/cmd/podman/sigproxy.go
@@ -0,0 +1,33 @@
+package main
+
+import (
+ "os"
+ "syscall"
+
+ "github.com/docker/docker/pkg/signal"
+ "github.com/projectatomic/libpod/libpod"
+ "github.com/sirupsen/logrus"
+)
+
+func ProxySignals(ctr *libpod.Container) {
+ sigBuffer := make(chan os.Signal, 128)
+ signal.CatchAll(sigBuffer)
+
+ logrus.Debugf("Enabling signal proxying")
+
+ go func() {
+ for s := range sigBuffer {
+ // Ignore SIGCHLD and SIGPIPE - these are mostly likely
+ // intended for the podman command itself.
+ if s == signal.SIGCHLD || s == signal.SIGPIPE {
+ continue
+ }
+
+ if err := ctr.Kill(uint(s.(syscall.Signal))); err != nil {
+ logrus.Errorf("Error forwarding signal %d to container %s: %v", s, ctr.ID(), err)
+ }
+ }
+ }()
+
+ return
+}