title: Unable to open "/var/run/tor/tor0.pid" for writing: Permission denied after multiple instances
body: <p>I am working on a tor server which need to load two instances (one hidden service and one relay). 
  When i'am using one instances it's working fine... but with <a href="https://www.torservers.net/wiki/setup/server#multiple_tor_processes" rel="nofollow">this tutorial</a> I have a permission problem on the pid </p>
  
  <p>With the original daemon it's working fine i'havent any problem of permission... </p>
  
  <p>But if i use <a href="https://gist.github.com/7adietri/9122199" rel="nofollow">this one</a> which add this :</p>
  
  <pre><code># --- Multi-instance init ---
  
  config="/etc/tor"
  arrrgs="$ARGS"
  command=$1
  shift
  instances=$*
  
  instances() {
      case $instances in
          "")
              for c in $config/*.cfg
              do
                  base=${c##*/}
                  test -f "$c" &amp;&amp; echo ${base%.cfg}
              done
              ;;
          *)
              echo "$instances"
              ;;
      esac
  }
  
  case "$command" in
      start|stop|restart|reload|force-reload|status)
          highest=0
          for i in $(instances)
          do
              NAME=$i
              DESC=$i
              TORPID="$TORPIDDIR/$i.pid"
              ARGS="$arrrgs -f $config/$i.cfg"
              execute $command
              status=$?
              test $status -gt $highest &amp;&amp; highest=$status
          done
          exit $highest
          ;;
      *)
          execute
          exit 1
          ;;
  esac
  </code></pre>
  
  <p>I have the error in the notice0/1.log </p>
  
  <p><em>Sep 29 16:47:10.000 [warn] Unable to open "/var/run/tor/tor0.pid" for writing: Permission denied</em></p>
  
  <p>So I-can't stop the instance of tor... How is-it possible ? How to correct-it ? What is the difference regarding permission between the first daemon (the original one) and the new one...</p>
  
  <p>Thanks a lot by advance</p>
  
  <p>EDIT : </p>
  
  <p>If in config I have  <strong>PidFile /var/run/tor/tor.pid</strong> it's working no permission problem but if I have <strong>PidFile /var/run/tor/tor0.pid</strong> permission error... What the ??</p>