Adds a timeout and cancel to shim fifo open
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-01-15 21:55:38 +09:00
committed by Ian Lewis
parent c120d7ee2d
commit f39907aa5d
2 changed files with 14 additions and 5 deletions
+6
View File
@@ -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 {
+8 -5
View File
@@ -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 {