Note that there are some explanatory texts on larger screens.

plurals
  1. POPiping output from one program to another not working for this particular program
    primarykey
    data
    text
    <p>I expect this is a basic question, but I haven't been able to find an answer.</p> <p>I'm building a web server in C++, and in order to help me visualise the system as it's running I'm building a separate program to do the visualisation. The web server will inform the visualiser of its current state by printing statements to stdout that are piped into the visualiser, which will parse the input and render a nice schematic view of the whole system along with various stats. The visualiser will be written in Python.</p> <p>To check that I understand how piping works I created two simple programs:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello world!\n"; return 0; } </code></pre> <p>, and</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { char buf[128]; while (!cin.eof()) { cin.getline(buf, 128, '\n'); cout &lt;&lt; "Received line: " &lt;&lt; buf &lt;&lt; "\n"; } return 0; } </code></pre> <p>This works as expected when I execute the command</p> <pre><code>./one | ./two </code></pre> <p>However, when I run my web server like so:</p> <pre><code>./aril | ./two </code></pre> <p>I get no output at all.</p> <p>Running the server on its own produces output like the following:</p> <pre><code>Spawning handlers Waiting for HTTP clients Server: got connection from 127.0.0.1, port 52168 Connection timed out </code></pre> <p>(Obviously that isn't actually the kind of output I'll be passing to the visualiser -- it will need a more easily parse-able syntax).</p> <p>Possibly relevant info:</p> <p>The web server is divided into two processes: aril and arild. aril runs with root privileges, whereas arild doesn't. Both processes print to stdout using std::cout.</p> <p>I can't think of any reason why this isn't working.</p> <p>EDIT: The solution, it turns out, is simply to explicitly flush the output. Should have been the first thing I tried really..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload