Merge changes from topic "stacks_envsetup"

* changes:
  stacks: match exactly before matching nonexactly.
  Add return code support to `pid`.
  Move pid, stacks from envsetup.sh to dedicated scripts.