summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/proc/exec.go6
-rw-r--r--pkg/proc/init.go13
2 files changed, 14 insertions, 5 deletions
diff --git a/pkg/proc/exec.go b/pkg/proc/exec.go
index f52e1afdd..9b729e917 100644
--- a/pkg/proc/exec.go
+++ b/pkg/proc/exec.go
@@ -191,6 +191,12 @@ func (e *execProcess) start(ctx context.Context) (err error) {
e.stdin = sc
}
var copyWaitGroup sync.WaitGroup
+ ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
+ defer func() {
+ if err != nil {
+ cancel()
+ }
+ }()
if socket != nil {
console, err := socket.ReceiveMaster()
if err != nil {
diff --git a/pkg/proc/init.go b/pkg/proc/init.go
index 8ed48b60b..a4bb1f20c 100644
--- a/pkg/proc/init.go
+++ b/pkg/proc/init.go
@@ -106,11 +106,8 @@ func New(id string, runtime *runsc.Runsc, stdio proc.Stdio) *Init {
}
// Create the process with the provided config
-func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
- var (
- err error
- socket *runc.Socket
- )
+func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
+ var socket *runc.Socket
if r.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
return errors.Wrap(err, "failed to create OCI runtime console socket")
@@ -149,6 +146,12 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
p.closers = append(p.closers, sc)
}
var copyWaitGroup sync.WaitGroup
+ ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
+ defer func() {
+ if err != nil {
+ cancel()
+ }
+ }()
if socket != nil {
console, err := socket.ReceiveMaster()
if err != nil {