// NewProcessInfo returns a new process info with the hostname concatenated to the name given
761527
func NewProcessInfo(name, namespace string) *ProcessInfo {
	// try to concat the hostname if available
	host, _ := os.Hostname()
	if host != "" {
		name = fmt.Sprintf("%s-%s", name, host)
	}
	return &ProcessInfo{
		Name:      name,
		Namespace: namespace,
	}
}
348921
func (process *TeleportProcess) newLocalCacheForProxy(clt auth.ClientI, cacheName []string) (auth.AccessPoint, error) {
	return process.newLocalCache(clt, cache.ForProxy, cacheName)
}
905973
func NewCustomRequestProcessor(address string) *RequestProcessor {
	r := NewRequestProcessor()

	if address != "" {
		r.address = address
	}

	return r
}
796773
func getProcessImageName() (name string) {
	name = filepath.Base(os.Args[0])
	name = strings.TrimRight(name, ".exe")
	return
}
428455
func validateProcessInfo(p *ProcessInfo) error {
	if p == nil {
		return fmt.Errorf("ProcessInfo must be set")
	} else if p.Name == "" {
		return fmt.Errorf("ProcessInfo name must be set")
	} else if p.Namespace == "" {
		return fmt.Errorf("ProcessInfo namespace must be set")
	}
	return nil
}
1027430
func NewPipeLine(p []Process) Process {
	if p == nil || len(p) == 0 {
		p = []Process{&CatProcess{}}
	}
	return &pipeline{
		stages: p,
	}
}
899197
func GetProcessMemoryInfo(handle syscall.Handle) (ProcessMemoryCountersEx, error) {
	processMemoryCountersEx := ProcessMemoryCountersEx{cb: sizeofProcessMemoryCountersEx}
	err := _GetProcessMemoryInfo(handle, &processMemoryCountersEx, processMemoryCountersEx.cb)
	if err != nil {
		return ProcessMemoryCountersEx{}, errors.Wrap(err, "GetProcessMemoryInfo failed")
	}

	return processMemoryCountersEx, nil
}
110206
func (s *Service) PipelineInfo(ctx context.Context, pipelineIdentity string) (*Pipeline, error) {
	var pipeline Pipeline
	return &pipeline, s.Get(ctx, &pipeline, fmt.Sprintf("/pipelines/%v", pipelineIdentity), nil, nil)
}
909245
func (p *Process) RedisInfo(addr string, timeout time.Duration) (*RedisInfo, error) {
	// Default to local process if addr not specified.
	if addr == "" {
		addr = fmt.Sprintf("localhost:%s", p.Port)
	}

	logger := p.Logger.New("fn", "replInfo", "addr", addr)
	logger.Info("sending INFO")

	// Connect to the redis server.
	conn, err := redis.Dial("tcp", addr,
		redis.DialPassword(p.Password),
		redis.DialConnectTimeout(timeout),
		redis.DialReadTimeout(timeout),
		redis.DialWriteTimeout(timeout),
	)
	if err != nil {
		logger.Info("dial error", "err", err)
		return nil, err
	}
	defer conn.Close()

	// Execute INFO command.
	reply, err := conn.Do("INFO")
	if err != nil {
		logger.Error("info error", "err", err)
		return nil, err
	}

	buf, ok := reply.([]byte)
	if !ok {
		logger.Error("info reply type error", "type", fmt.Sprintf("%T", buf))
		return nil, fmt.Errorf("unexpected INFO reply format: %T", buf)
	}

	// Parse the bulk string reply info a typed object.
	info, err := ParseRedisInfo(string(buf))
	if err != nil {
		logger.Error("parse info error", "err", err)
		return nil, fmt.Errorf("parse info: %s", err)
	}

	logger.Info("INFO received")
	return info, nil
}
653955
func findProcessWithPID(pid int) (ps.Process, error) {
	matchPID := func(p ps.Process) bool { return p.Pid() == pid }
	procs, err := findProcessesWithFn(ps.Processes, matchPID, 1)
	if err != nil {
		return nil, err
	}
	if len(procs) == 0 {
		return nil, nil
	}
	return procs[0], nil
}
111499
func New(pid int) *Process {
	dbp := &Process{
		pid:            pid,
		threads:        make(map[int]*Thread),
		breakpoints:    proc.NewBreakpointMap(),
		firstStart:     true,
		os:             new(OSProcessDetails),
		ptraceChan:     make(chan func()),
		ptraceDoneChan: make(chan interface{}),
		bi:             proc.NewBinaryInfo(runtime.GOOS, runtime.GOARCH),
	}
	go dbp.handlePtraceFuncs()
	return dbp
}
1318214
func NewProc(fname string) (*Proc, error) {
	f, err := os.Open(fname)
	if err != nil {
		return nil, err
	}
	return &Proc{File: f, Buf: bufio.NewReader(f)}, nil
}
491994
func newKeyInfo(subscriptionPublicKey, serverPublicKey []byte) []byte {
	info := make([]byte, len(keyInfoPrefix)+len(subscriptionPublicKey)+len(serverPublicKey))
	n := copy(info, keyInfoPrefix)
	n += copy(info[n:], subscriptionPublicKey)
	copy(info[n:], serverPublicKey)
	return info
}
1097824
func (container *container) CreateProcess(c *ProcessConfig) (Process, error) {
	p, err := container.system.CreateProcess(c)
	if err != nil {
		return nil, convertSystemError(err, container)
	}
	return &process{p: p}, nil
}
613257
func (s *AwsSecurityFindingFilters) SetProcessPid(v []*NumberFilter) *AwsSecurityFindingFilters {
	s.ProcessPid = v
	return s
}
735059
func (p *Plugin) NewProcessFromTemplate(tmp *process.Template) ProcessInstance {
	newTmpPr, err := p.templateToProcess(tmp)
	if err != nil {
		p.Log.Errorf("cannot create a process from template: %v", err)
		return nil
	}
	p.processes = append(p.processes, newTmpPr)

	go newTmpPr.watch()

	return newTmpPr
}
83415
func NewInfo(environment string) Info {
	if environment == "" {
		environment = EnvironmentProduction
	}
	return Info{
		CommitHash:  commitHash,
		BuildDate:   buildDate,
		Environment: environment,
	}
}