@@ -97,7 +97,10 @@ func getDefaultImagePath(context *cli.Context) string {
9797
9898// newProcess returns a new libcontainer Process with the arguments from the
9999// spec and stdio from the current process.
100- func newProcess (p specs.Process ) (* libcontainer.Process , error ) {
100+ func newProcess (p * specs.Process ) (* libcontainer.Process , error ) {
101+ if p == nil {
102+ return & libcontainer.Process {}, nil
103+ }
101104 lp := & libcontainer.Process {
102105 Args : p .Args ,
103106 Env : p .Env ,
@@ -261,7 +264,7 @@ func (r *runner) run(config *specs.Process) (int, error) {
261264 r .destroy ()
262265 return - 1 , err
263266 }
264- process , err := newProcess (* config )
267+ process , err := newProcess (config )
265268 if err != nil {
266269 r .destroy ()
267270 return - 1 , err
@@ -291,7 +294,8 @@ func (r *runner) run(config *specs.Process) (int, error) {
291294 // with detaching containers, and then we get a tty after the container has
292295 // started.
293296 handler := newSignalHandler (r .enableSubreaper , r .notifySocket )
294- tty , err := setupIO (process , rootuid , rootgid , config .Terminal , detach , r .consoleSocket )
297+ terminal := config != nil && config .Terminal
298+ tty , err := setupIO (process , rootuid , rootgid , terminal , detach , r .consoleSocket )
295299 if err != nil {
296300 r .destroy ()
297301 return - 1 , err
@@ -353,17 +357,21 @@ func (r *runner) terminate(p *libcontainer.Process) {
353357
354358func (r * runner ) checkTerminal (config * specs.Process ) error {
355359 detach := r .detach || (r .action == CT_ACT_CREATE )
360+ terminal := config != nil && config .Terminal
356361 // Check command-line for sanity.
357- if detach && config . Terminal && r .consoleSocket == "" {
362+ if detach && terminal && r .consoleSocket == "" {
358363 return fmt .Errorf ("cannot allocate tty if runc will detach without setting console socket" )
359364 }
360- if (! detach || ! config . Terminal ) && r .consoleSocket != "" {
365+ if (! detach || ! terminal ) && r .consoleSocket != "" {
361366 return fmt .Errorf ("cannot use console socket if runc will not detach or allocate tty" )
362367 }
363368 return nil
364369}
365370
366371func validateProcessSpec (spec * specs.Process ) error {
372+ if spec == nil {
373+ return nil
374+ }
367375 if spec .Cwd == "" {
368376 return fmt .Errorf ("Cwd property must not be empty" )
369377 }
0 commit comments