add pkg/signal

Add pkg/signal to deal with parts of signal processing and translating
signals from string to numeric representations.  The code has been
copied from docker/docker (and attributed with the copyright) but been
reduced to only what libpod needs (on Linux).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2020-02-12 11:10:55 +01:00
parent 156ce5cd7d
commit 85b7374491
19 changed files with 90 additions and 399 deletions

View File

@ -3,9 +3,9 @@ package adapter
import (
"context"
"os"
gosignal "os/signal"
"os/signal"
"github.com/docker/docker/pkg/signal"
lsignal "github.com/containers/libpod/pkg/signal"
"github.com/docker/docker/pkg/term"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@ -33,7 +33,7 @@ func getResize() *remotecommand.TerminalSize {
// Helper for prepareAttach - set up a goroutine to generate terminal resize events
func resizeTty(ctx context.Context, resize chan remotecommand.TerminalSize) {
sigchan := make(chan os.Signal, 1)
gosignal.Notify(sigchan, signal.SIGWINCH)
signal.Notify(sigchan, lsignal.SIGWINCH)
go func() {
defer close(resize)
// Update the terminal size immediately without waiting