agent/api/task/task.go
func (task *Task) shouldOverridePIDMode(container *apicontainer.Container, dockerContainerMap map[string]*apicontainer.DockerContainer) (bool, string) {
	// If the container is an internal container (ContainerEmptyHostVolume,
	// ContainerCNIPause, or ContainerNamespacePause), then PID namespace for
	// the container itself should be private (default Docker option)
	if container.IsInternal() {
		return false, ""
	}

	switch task.getPIDMode() {
	case pidModeHost:
		return true, pidModeHost

	case pidModeTask:
		pauseCont, ok := task.ContainerByName(NamespacePauseContainerName)
		if !ok {
			seelog.Criticalf("Namespace Pause container not found in the task: %s; Setting Task's Desired Status to Stopped", task.Arn)
			task.SetDesiredStatus(apitaskstatus.TaskStopped)
			return false, ""
		}
		pauseDockerID, ok := dockerContainerMap[pauseCont.Name]
		if !ok || pauseDockerID == nil {
			// Docker container shouldn't be nil or not exist if the Container definition within task exists; implies code-bug
			seelog.Criticalf("Namespace Pause docker container not found in the task: %s; Setting Task's Desired Status to Stopped", task.Arn)
			task.SetDesiredStatus(apitaskstatus.TaskStopped)
			return false, ""
		}
		return true, dockerMappingContainerPrefix + pauseDockerID.DockerID

		// If PIDMode is not Host or Task, then no need to override
	default:
		return false, ""
	}
}
func (task *Task) shouldOverridePIDMode(container *apicontainer.Container, dockerContainerMap map[string]*apicontainer.DockerContainer) (bool, string) {
	// If the container is an internal container (ContainerEmptyHostVolume,
	// ContainerCNIPause, or ContainerNamespacePause), then PID namespace for
	// the container itself should be private (default Docker option)
	if container.IsInternal() {
		return false, ""
	}

	switch task.getPIDMode() {
	case pidModeHost:
		return true, pidModeHost

	case pidModeTask:
		pauseCont, ok := task.ContainerByName(NamespacePauseContainerName)
		if !ok {
			seelog.Criticalf("Namespace Pause container not found in the task: %s; Setting Task's Desired Status to Stopped", task.Arn)
			task.SetDesiredStatus(apitaskstatus.TaskStopped)
			return false, ""
		}
		pauseDockerID, ok := dockerContainerMap[pauseCont.Name]
		if !ok || pauseDockerID == nil {
			// Docker container shouldn't be nil or not exist if the Container definition within task exists; implies code-bug
			seelog.Criticalf("Namespace Pause docker container not found in the task: %s; Setting Task's Desired Status to Stopped", task.Arn)
			task.SetDesiredStatus(apitaskstatus.TaskStopped)
			return false, ""
		}
		return true, dockerMappingContainerPrefix + pauseDockerID.DockerID

		// If PIDMode is not Host or Task, then no need to override
	default:
		return false, ""
	}
}
// shouldOverridePIDMode returns true if the PIDMode of the container needs
// to be overridden. It also returns the override string in this case. It returns
// false otherwise