Why does exec(escapeshellcmd("rm -rf /var/www/temp/storage/$userId/")) remove the parent directory when the php file runs in the background?
<p>I have the following two php scripts</p>

<p><strong>remove_directory.php</strong></p>

<pre><code>&lt;?php
start_session();
$userId = $_SESSION['userId'];
exec(escapeshellcmd("rm -rf /var/www/temp/storage/$userId/"));
?&gt;
</code></pre>

<p><strong>indirectly_remove_directory.php</strong></p>

<pre><code>&lt;?php
start_session();
exec("nohup php remove_directory.php &gt; /var/www/temp/log.txt &amp;"); 
?&gt;
</code></pre>

<p>When I run <code>remove_directory.php</code> from the cgi, it works as expected, recursively removing <code>/var/www/temp/storage/$userId/</code> but when I run <code>indirectly_remove_directory.php</code> from the cgi, it does not work as expected since it recursively removes <code>/var/www/temp/storage/</code>.  </p>

<p>Why does the entire storage directory get removed when I run <code>indirectly_remove_directory.php</code>?</p>
