title: Bash: Using pkill to track progress of removing a directory
body: <p>So I have a shell script that does some long operations, and when they do I want to just output a series of dots (.) until it's done, to show that it's running.</p>
  
  <p>I'm using pkill to test that the process is running, and as long as it is it outputs another dot. This works very well for nearly every place I need it. However, one part of the process involves removing a directory, and that is where it breaks down.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ERROR=$(rm -rf "$1" 2&gt;&amp;1 &gt;/dev/null)
      while pkill -0 rm; do
          printf "."
          sleep 1
      done
      printf "\n"
  </code></pre>
  
  <p>I'm using pkill to test the rm process, but when I do, this is the output I get:</p>
  
  <pre><code>pkill: signalling pid 192: Operation not permitted
  
  pkill: signalling pid 326: Operation not permitted
  
  .pkill: signalling pid 61: Operation not permitted
  </code></pre>
  
  <p>My script runs up until the dot-output code, including the folder deletion, but then it stops and just outputs those three lines over and over again until I forcibly kill the process.</p>
  
  <p>Anyone have any ideas what's going on? I feel like it's not able to work with the rm operation, but I'm not sure.</p>
  
  <p>Thanks in advance.</p>