title: Start and stop minecraft (java process) via php
body: <p>OK, let me try again.  :-)</p>
  
  <p>If I try:</p>
  
  <pre><code>&lt;?php
  exec("java -Xms1024M -Xmx1024M -jar craftbukkit-1.4.2-R0.2.jar -o true");
  ?&gt;
  </code></pre>
  
  <p>The web page never returns.  I believe it is because the CGI is waiting for the process to complete, which of course it never does because it is a server.</p>
  
  <p>I try this locally and if I put the same command in the terminal it runs as expected so I know there is no problem with the command line.</p>
  
  <p>So...the question is:</p>
  
  <p>1) does exec block until the process completes?
  2) if no, what is happening here, if yes, how can I change that behavior?</p>
  
  <p>=============================================================</p>
  
  <p>So this is really a generic question, but I have included to the specific environment which might help to explain why I am trying to do this.  This is all on LINUX.</p>
  
  <p>I want to launch a Java process remotely from a PHP page.  The trick of course is that the process will keep running and I want to the PHP page complete once the process has successfully launched.</p>
  
  <p>So, first how do I do that?  I've tried a number of things I've read and can't get them to work.</p>
  
  <p>The second part is a little more tricky.  The way you stop the minecraft server, is in the terminal you type "Stop".  And of course you can enter other commands there to do other things...its just reading from stdin.</p>
  
  <p>If I want to stop it, or send it other commands, I need to connect to stdin from a PHP script and send it text or something.</p>
  
  <p>When I launch the java process, do I connect stdin to a file and then from future PHP scripts write to the file?  I don't know. </p>
  
  <p>Just give me a few pointers on the right approach and will try them.  I'll let you know if they work or if I have more detailed questions.</p>
  
  <p>Thanks!</p>