Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot do what you want in the general case (unbuffering after <a href="http://man7.org/linux/man-pages/man2/execve.2.html" rel="nofollow noreferrer"><code>execve(2)</code></a> of arbitrary executables...)</p> <p>Buffering is done by code (e.g. by some <code>libc</code> code related to <code>&lt;stdio.h&gt;</code>). And the code is defined by the program being <code>execve</code>-ed.</p> <p>You might perhaps play with <a href="http://www.catonmat.net/blog/simple-ld-preload-tutorial/" rel="nofollow noreferrer">LD_PRELOAD tricks</a> which might call <code>setvbuf(stdin, NULL, _IONBF, BUFSIZ);</code> <em>after</em> the <code>execve</code> (but before the <code>main</code>....); but this would work only with dynamically linked executables.</p> <p>Perhaps using some <code>constructor</code> <a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html" rel="nofollow noreferrer">function attribute</a> in some initialization function of your <code>LD_PRELOAD</code>-ed shared object might <em>sometimes</em> do the trick. Or redefine <code>printf</code>, <code>fopen</code>, .... in that shared object...</p> <h3>addenda</h3> <p>You commented that you do :</p> <blockquote> <p>two-way communication with a sub-process using two pipes.</p> </blockquote> <p>Then your approach is wrong. The parent process should monitor the two pipes, probably with a multiplexing call like <a href="http://man7.org/linux/man-pages/man2/poll.2.html" rel="nofollow noreferrer">poll(2)</a>, then (according to the result of that multiplexing) decide to read or to write to the child process. In reality, you want some <a href="https://en.wikipedia.org/wiki/Event_loop" rel="nofollow noreferrer">event loop</a>: either implement a simple <strong>event <em>loop</em></strong> yourself (with e.g. <code>poll</code> [iteratively called many times] inside a repeated <em>loop</em>) or use some existing one (see <a href="http://libevent.org/" rel="nofollow noreferrer">libevent</a> or <a href="http://software.schmorp.de/pkg/libev.html" rel="nofollow noreferrer">libev</a>, or the one provided by some toolkit like <a href="http://www.gtk.org/" rel="nofollow noreferrer">GTK</a> or <a href="http://qt-project.org/qt5" rel="nofollow noreferrer">Qt</a> etc...)</p> <p><sup>You might also multiplex with <a href="http://man7.org/linux/man-pages/man2/select.2.html" rel="nofollow noreferrer">select(2)</a> but I recommend <code>poll</code> because of the <a href="https://en.wikipedia.org/wiki/C10k_problem" rel="nofollow noreferrer">C10K problem</a></sup></p> <p>You won't lose your time by reading <a href="http://advancedlinuxprogramming.com/" rel="nofollow noreferrer">Advanced Linux Programming</a> ...</p> <p>See also <a href="https://stackoverflow.com/a/20582916/841108">this answer</a> to your next related question.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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