<commit_before>package containerd

import (
	"context"
	"syscall"

	eventsapi "github.com/containerd/containerd/api/services/events/v1"
	"github.com/containerd/containerd/api/services/tasks/v1"
	"github.com/containerd/containerd/typeurl"
	specs "github.com/opencontainers/runtime-spec/specs-go"
)

type process struct {
	id   string
	task *task
	pid  uint32
	io   *IO
	spec *specs.Process
}

func (p *process) ID() string {
	return p.id
}

// Pid returns the pid of the process
// The pid is not set until start is called and returns
func (p *process) Pid() uint32 {
	return p.pid
}

// Start starts the exec process
func (p *process) Start(ctx context.Context) error {
	any, err := typeurl.MarshalAny(p.spec)
	if err != nil {
		return err
	}
	request := &tasks.ExecProcessRequest{
		ContainerID: p.task.id,
		ExecID:      p.id,
		Terminal:    p.io.Terminal,
		Stdin:       p.io.Stdin,
		Stdout:      p.io.Stdout,
		Stderr:      p.io.Stderr,
		Spec:        any,
	}
	response, err := p.task.client.TaskService().Exec(ctx, request)
	if err != nil {
		p.io.Close()
		return err
	}<commit_msg>Fix data race when task's exec fails to start<commit_after>package containerd

import (
	"context"
	"syscall"

	eventsapi "github.com/containerd/containerd/api/services/events/v1"
	"github.com/containerd/containerd/api/services/tasks/v1"
	"github.com/containerd/containerd/typeurl"
	specs "github.com/opencontainers/runtime-spec/specs-go"
)

type process struct {
	id   string
	task *task
	pid  uint32
	io   *IO
	spec *specs.Process
}

func (p *process) ID() string {
	return p.id
}

// Pid returns the pid of the process
// The pid is not set until start is called and returns
func (p *process) Pid() uint32 {
	return p.pid
}

// Start starts the exec process
func (p *process) Start(ctx context.Context) error {
	any, err := typeurl.MarshalAny(p.spec)
	if err != nil {
		return err
	}
	request := &tasks.ExecProcessRequest{
		ContainerID: p.task.id,
		ExecID:      p.id,
		Terminal:    p.io.Terminal,
		Stdin:       p.io.Stdin,
		Stdout:      p.io.Stdout,
		Stderr:      p.io.Stderr,
		Spec:        any,
	}
	response, err := p.task.client.TaskService().Exec(ctx, request)
	if err != nil {
		p.io.Wait()
		p.io.Close()
		return err
	}
{'fraction_non_alphanumeric': 0.12634892086330934, 'fraction_numerical': 0.00539568345323741, 'mean_word_length': 3.1823308270676693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1937459', 'n_tokens_mistral': 860, 'n_tokens_neox': 826, 'n_words': 211}