title: Why does this inotifywait shellscript shop up with two PIDs?
body: <p>I am learning to use inotifywait, specifically by using the script at: <a href="https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files">https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files</a>. What I do not understand is why my scripts always appear two times when I use <code>pid x</code>.</p>
  
  <pre><code>36285 pts/1    S+     0:00 /bin/bash ./observe2.sh /home/user1/testfolder
  36286 pts/1    S+     0:00 inotifywait -m /home/user1/testfolder -e create -e moved_to
  36287 pts/1    S+     0:00 /bin/bash ./observe2.sh /home/user1/testfolder
  </code></pre>
  
  <p>For quicker testing, I changed the linked script so that you can pass any folder via $1 to be observed, and saved as <code>observe2.sh</code>:</p>
  
  <pre><code>#!/bin/bash
  inotifywait -m $1 -e create -e moved_to |
      while read path action file; do
          echo "The file '$file' appeared in directory '$path' via '$action'"
          # do something with the file
      done
  </code></pre>
  
  <p>Why does the script process show up two times? Is there a fork somewhere in the process? Could somebody explain why exactly this behavior of two processes is happening?</p>