windows: Create init process with task

This prevents `task.Wait()` to return an error if it is called before the task
is started.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2017-10-06 13:38:08 -07:00
parent ad5266456c
commit cfa87567a0
4 changed files with 25 additions and 9 deletions

View File

@@ -111,17 +111,16 @@ func (t *task) Info() runtime.TaskInfo {
}
func (t *task) Start(ctx context.Context) error {
if p := t.getProcess(t.id); p != nil {
return errors.Wrap(errdefs.ErrFailedPrecondition, "task already started")
p := t.getProcess(t.id)
if p == nil {
panic("init process is missing")
}
conf := newWindowsProcessConfig(t.spec.Process, t.io)
p, err := t.newProcess(ctx, t.id, conf, t.io)
if err != nil {
return err
if p.Status() != runtime.CreatedStatus {
return errors.Wrap(errdefs.ErrFailedPrecondition, "process was already started")
}
if err := p.Start(ctx); err != nil {
t.removeProcess(t.id)
return err
}
t.publisher.Publish(ctx,