code: func (p *Plugin) AttachProcess(name string, cmd string, pid int, options ...POption) (ProcessInstance, error) {
  	pr, err := os.FindProcess(pid)
  	if err != nil {
  		return nil, errors.Errorf("cannot attach to process with PID %d: %v", pid, err)
  	}
  	attachedPr := &Process{
  		log:        p.Log,
  		name:       name,
  		cmd:        cmd,
  		options:    &POptions{},
  		command:    &exec.Cmd{Process: pr},
  		sh:         &status.Reader{Log: p.Log},
  		cancelChan: make(chan struct{}),
  	}
  	for _, option := range options {
  		option(attachedPr.options)
  	}
  	p.processes = append(p.processes, attachedPr)
  
  	attachedPr.status, err = attachedPr.sh.ReadStatusFromPID(attachedPr.GetPid())
  	if err != nil {
  		p.Log.Warnf("failed to read process (PID %d) status: %v", pid, err)
  	}
  
  	go attachedPr.watch()
  
  	if attachedPr.options.template {
  		p.writeAsTemplate(attachedPr)
  	}
  
  	return attachedPr, nil
  }
docs: // AttachProcess attaches to existing process, reads its status and starts process status watcher