summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/process.go
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2019-11-13 10:30:08 -0500
committerTomSweeneyRedHat <tsweeney@redhat.com>2019-11-13 10:57:19 -0500
commit6003033adae775f1d725b05231a246a4462ae669 (patch)
treec570c523df92c3c0fb4b704c5c45b0de6603b7d6 /vendor/github.com/Microsoft/hcsshim/process.go
parentde32b89eff0928abdef9d85a420b65d8865e737e (diff)
downloadpodman-6003033adae775f1d725b05231a246a4462ae669.tar.gz
podman-6003033adae775f1d725b05231a246a4462ae669.tar.bz2
podman-6003033adae775f1d725b05231a246a4462ae669.zip
Bump to Buildah v1.11.5
Bump to Buildah v1.11.5. Most notably changes to the podman build `--pull` functionality. `--pull=true` and `--pull=false` now work as Docker does, `--pull-never` added to supply the functionality of the old `--pull=false`. Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/process.go')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/process.go38
1 files changed, 32 insertions, 6 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/process.go b/vendor/github.com/Microsoft/hcsshim/process.go
index ca8acbb7c..3362c6833 100644
--- a/vendor/github.com/Microsoft/hcsshim/process.go
+++ b/vendor/github.com/Microsoft/hcsshim/process.go
@@ -1,7 +1,9 @@
package hcsshim
import (
+ "context"
"io"
+ "sync"
"time"
"github.com/Microsoft/hcsshim/internal/hcs"
@@ -9,7 +11,10 @@ import (
// ContainerError is an error encountered in HCS
type process struct {
- p *hcs.Process
+ p *hcs.Process
+ waitOnce sync.Once
+ waitCh chan struct{}
+ waitErr error
}
// Pid returns the process ID of the process within the container.
@@ -19,7 +24,14 @@ func (process *process) Pid() int {
// Kill signals the process to terminate but does not wait for it to finish terminating.
func (process *process) Kill() error {
- return convertProcessError(process.p.Kill(), process)
+ found, err := process.p.Kill(context.Background())
+ if err != nil {
+ return convertProcessError(err, process)
+ }
+ if !found {
+ return &ProcessError{Process: process, Err: ErrElementNotFound, Operation: "hcsshim::Process::Kill"}
+ }
+ return nil
}
// Wait waits for the process to exit.
@@ -30,7 +42,21 @@ func (process *process) Wait() error {
// WaitTimeout waits for the process to exit or the duration to elapse. It returns
// false if timeout occurs.
func (process *process) WaitTimeout(timeout time.Duration) error {
- return convertProcessError(process.p.WaitTimeout(timeout), process)
+ process.waitOnce.Do(func() {
+ process.waitCh = make(chan struct{})
+ go func() {
+ process.waitErr = process.Wait()
+ close(process.waitCh)
+ }()
+ })
+ t := time.NewTimer(timeout)
+ defer t.Stop()
+ select {
+ case <-t.C:
+ return &ProcessError{Process: process, Err: ErrTimeout, Operation: "hcsshim::Process::Wait"}
+ case <-process.waitCh:
+ return process.waitErr
+ }
}
// ExitCode returns the exit code of the process. The process must have
@@ -45,14 +71,14 @@ func (process *process) ExitCode() (int, error) {
// ResizeConsole resizes the console of the process.
func (process *process) ResizeConsole(width, height uint16) error {
- return convertProcessError(process.p.ResizeConsole(width, height), process)
+ return convertProcessError(process.p.ResizeConsole(context.Background(), width, height), process)
}
// Stdio returns the stdin, stdout, and stderr pipes, respectively. Closing
// these pipes does not close the underlying pipes; it should be possible to
// call this multiple times to get multiple interfaces.
func (process *process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, error) {
- stdin, stdout, stderr, err := process.p.Stdio()
+ stdin, stdout, stderr, err := process.p.StdioLegacy()
if err != nil {
err = convertProcessError(err, process)
}
@@ -62,7 +88,7 @@ func (process *process) Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, e
// CloseStdin closes the write side of the stdin pipe so that the process is
// notified on the read side that there is no more data in stdin.
func (process *process) CloseStdin() error {
- return convertProcessError(process.p.CloseStdin(), process)
+ return convertProcessError(process.p.CloseStdin(context.Background()), process)
}
// Close cleans up any state associated with the process but does not kill