summaryrefslogtreecommitdiff
path: root/cmd/podman/sigproxy.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-03-04 12:24:56 -0500
committerMatthew Heon <matthew.heon@gmail.com>2018-03-15 16:00:20 -0400
commitcd73a6904d3dc91f305c7415ab7bada8a976d815 (patch)
treef801bda8d9b6eb4726f1c6c41d33cd877d5246ff /cmd/podman/sigproxy.go
parent647fedc2a2bc84a3e199ae86d5a7c6608d3968cc (diff)
downloadpodman-cd73a6904d3dc91f305c7415ab7bada8a976d815.tar.gz
podman-cd73a6904d3dc91f305c7415ab7bada8a976d815.tar.bz2
podman-cd73a6904d3dc91f305c7415ab7bada8a976d815.zip
Add signal proxying to podman run, start, and attach
Also removes sig-proxy from 'podman create', where is does not make sense. Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
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
+}