// NewTask creates a new task defined by cfg.
//
// NewTask does not start the returned task; the caller must call Task.Start.
//
// If successful, NewTask transfers references held by cfg to the new task.
// Otherwise, NewTask releases them.
NewTask creates a new task defined by cfg.

NewTask does not start the returned task; the caller must call Task.Start.

If successful, NewTask transfers references held by cfg to the new task.
Otherwise, NewTask releases them.
// NewTask creates a new task defined by cfg . // // NewTask does not start the returned task ; the caller must call Task . Start . // // If successful NewTask transfers references held by cfg to the new task . // Otherwise NewTask releases them .
func (ts *TaskSet) NewTask(ctx context.Context, cfg *TaskConfig) (*Task, error) {
	t, err := ts.newTask(cfg)
	if err != nil {
		cfg.TaskImage.release()
		cfg.FSContext.DecRef(ctx)
		cfg.FDTable.DecRef(ctx)
		cfg.IPCNamespace.DecRef(ctx)
		if cfg.MountNamespaceVFS2 != nil {
			cfg.MountNamespaceVFS2.DecRef(ctx)
		}
		return nil, err
	}
	return t, nil
}
func ( ts * TaskSet ) NewTask ( ctx context . Context , cfg * TaskConfig ) ( * Task , error ) { t , err := ts . newTask ( cfg ) if err != nil { cfg . TaskImage . release ( ) cfg . FSContext . DecRef ( ctx ) cfg . FDTable . DecRef ( ctx ) cfg . IPCNamespace . DecRef ( ctx ) if cfg . MountNamespaceVFS2 != nil { cfg . MountNamespaceVFS2 . DecRef ( ctx ) } return nil , err } return t , nil }
NewTask creates a new task defined by cfg.
NewTask creates a new task defined by cfg .