title: Imposibility to start an independet, background long task with HTTP post/get request without freezing the browser
body: <p>I have made any possible attempt.</p>
  <p><strong>Context:</strong></p>
  <ol>
  <li>shared hosting, no access to the shell</li>
  <li>any kill and exec PHP command disabled</li>
  </ol>
  <p><strong>Purpose</strong></p>
  <ol>
  <li>start a long process in the background by a post form request</li>
  <li>update the background process state in a file</li>
  <li>possibly read from the browser on periodic intervals the progress state (not necessary)</li>
  <li>continue to use the user session in the same browser to do other things in the same website login pages</li>
  <li>kill the process if needed by sending a specific command. Since PHP kill functions are not available, the PHPP function that receive the request write a kill command on a file that is periodically read by the background process. If the kill comand is detected the background process end safely.</li>
  </ol>
  <p><strong>Solution 1: FORKING</strong></p>
  <ol>
  <li>the request for stating the job is sent in a private login session by an ajax post request</li>
  <li>the starting PHP function forks itself. The parent is not waiting for the children ending and it flushes a JSON answer (&quot;process_began&quot;) and exits</li>
  <li>the children continue in the background the process</li>
  </ol>
  <p>The logic works, BUT</p>
  <ol>
  <li>the browser freezes itself waiting for the children to end as the forking procedure was not changing anything. I found around that this is because Apache considers the children as for the same request from the browser.</li>
  <li>if the killing procedure is called it is piped waiting for the children to end</li>
  <li>opening a different browser, for instance, the first Chrome the second IE, if the killing procedure is called by IE, it works properly, the background process is ended.</li>
  </ol>
  <p><strong>Solution 2: calling a second function that performs the long job with a PHP CURL request and a very short timeout (1s) so that the calling function is not waiting for the answer;calling and called functions are in the same server and controller</strong></p>
  <p>The logic works, but I have the same problems of solution 1. The browser freezes and waits for the long job to be completed. No other pages of the private login session are available in the meantime as well as the ajax kill request is piped.</p>
  <p>How can I get the request of starting the long background making the browser not waiting for the response and the server accepting another request from the same user and browser? I believe that using web forms for sending long files for bulk uploads or long elaborations is a common need; does a solution really not exist for these cases? Thank you.</p>
  <p>(I have not attached code because it seems to me more conceptual trouble related to the environment and web server logic rather than to the code that is correct, I don't have errors; in case of need I can anyway add some code).</p>