[squeak-dev] FFI and capturing external program input in
Squeak/Pharo
David T. Lewis
lewis at mail.msen.com
Sun Jun 19 12:51:58 UTC 2011
On Fri, Jun 17, 2011 at 10:26:18AM -0700, Eliot Miranda wrote:
>
> On Fri, Jun 17, 2011 at 9:34 AM, Dave Mason <dmason at mason-rose.ca> wrote:
>
> > but I need to be able to get the output from
> > popen("echo \"#include <unistd.h>\"|gcc -E -","r")
>
> or equivalent.
>
>
> OSProcess would work. Also system would work.
>
To see how the lower level parts are done in OSProcess, step slowly
through "OSPipe open" in a debugger.
The sqFile data structures for the two pipe endpoints are created in
OSProcessPlugin>>primitiveCreatePipe. These data structures are mapped
into filestreams in OSPipe>>makePipe. See the unit tests for example usage.
Package CommandShell makes heavy use of OSPipe and contains additional tests.
Be careful not to read from a blocking pipe, as this will block your VM.
On Unix, the external process closing its pipe end results in a SIGPIPE
signal, which is handled elsewhere in OSProcess.
HTH,
Dave
More information about the Squeak-dev
mailing list
|