github.com/georgethebeatle/containerd@v0.2.5/supervisor/add_process.go (about) 1 package supervisor 2 3 import ( 4 "time" 5 6 "github.com/docker/containerd/runtime" 7 "github.com/docker/containerd/specs" 8 ) 9 10 // AddProcessTask holds everything necessary to add a process to a 11 // container 12 type AddProcessTask struct { 13 baseTask 14 ID string 15 PID string 16 Stdout string 17 Stderr string 18 Stdin string 19 ProcessSpec *specs.ProcessSpec 20 StartResponse chan StartResponse 21 } 22 23 func (s *Supervisor) addProcess(t *AddProcessTask) error { 24 start := time.Now() 25 ci, ok := s.containers[t.ID] 26 if !ok { 27 return ErrContainerNotFound 28 } 29 process, err := ci.container.Exec(t.PID, *t.ProcessSpec, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr)) 30 if err != nil { 31 return err 32 } 33 if err := s.monitorProcess(process); err != nil { 34 return err 35 } 36 ExecProcessTimer.UpdateSince(start) 37 t.StartResponse <- StartResponse{} 38 s.notifySubscribers(Event{ 39 Timestamp: time.Now(), 40 Type: StateStartProcess, 41 PID: t.PID, 42 ID: t.ID, 43 }) 44 return nil 45 }