title: Send commands to a process with fwrite [PHP]
body: <p>I'm developing a little GUI to interact with <code>mpsyt</code> through browser. I wrote this script:</p>
  
  <pre><code>&lt;?php
  file_put_contents("running.txt", true);
  $cwd = '/var/www/html';
  $pipes = array();
  $descriptors = array(
      0 =&gt; array("pipe", "r"),
      1 =&gt; array("pipe", "w"),
      2 =&gt; array("pipe", "w"));
  $process = proc_open("sudo mpsyt", $descriptors, $pipes, $cwd);
  $info = proc_get_status($process);
  stream_set_blocking($pipes[0], 0);
  stream_set_blocking($pipes[1], 0);
  $terminate = false;
  while (!$terminate) {
      $command = file_get_contents("command.txt");
      if ($command !== "") {
          if ($command == "terminate") {
              $terminate = true;
          }
          if ($command == "pause") {
              fwrite($pipes[0], " "); //&lt;---HERE
          } else {
              fwrite($pipes[0], $command);
          }
          fflush($pipes[0]);
          file_put_contents("command.txt", "");
      }
      if (($txt = stream_get_contents($pipes[1])) != "") {
          $txt = preg_replace('#\R+#', '&lt;/p&gt;&lt;p&gt;', $txt);
          file_put_contents("content.txt", $txt);
      }
      usleep(100000);
  }
  file_put_contents("content.txt", "");
  fclose($pipe[0]);
  fclose($pipe[1]);
  proc_close($process);
  file_put_contents("running.txt", false);
  </code></pre>
  
  <p>The problem is that <code>mpsyt</code> require to press <code>spacebar</code> to pause a song. How can i simulate this action with <code>fwrite()</code> (or else)?
  Googling, I found this thread (same question): </p>
  
  <p><a href="https://github.com/mps-youtube/mps-youtube/issues/568" rel="nofollow noreferrer">https://github.com/mps-youtube/mps-youtube/issues/568</a></p>
  
  <p>with this advertisement:</p>
  
  <p><a href="https://github.com/mpv-player/mpv/commit/a037f7b" rel="nofollow noreferrer">https://github.com/mpv-player/mpv/commit/a037f7b</a></p>
  
  <p>Is there any way to bypass this situation?
  Thanks in advance! </p>
  
  <p>P.S. I also tried to send the <code>SIGINT</code> signal (if you press <code>Ctrl-C</code> while is playing a song, it will stop) but it seems the process ignores it.</p>