Pipe buffering, accessing C-style stdin/stdout

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pipe buffering, accessing C-style stdin/stdout

Ingemar Ragnemalm

Sorry for not replying "in thread", I get the list as digest so I can't
"reply" properly.

 > > The problem with FPC is that I
 > > can't find any straightforward way to either get PFile-style
 > > stdin/stdout from the Text-style input/output (surely there is a
 > > connection?)

 > Yes. PFile _IS_ Text style.  PFile is the C wrapper implementing buffer,
 > Text the analogue Pascal buffering.  I assume that settextbuf to 0
didn't work?
 >
 > ( http://www.freepascal.org/docs-html/rtl/system/settextbuf.html )

I have tried that, but nothing good happened. I don't know how to apply
that to Input/Output in a TProcess.

 > If that doesn't work, you need to go back to the raw unbuffered IO, do a
 > IOCTL if necessary.  FPOpen, FPClose, FPWrite, FPRead

That's what I have been struggling with (apart from TProcess); pipe, fork,
dup, ioctl, read, write. I think I figured out how to access
stdin/stdout (by
importing __sF and calculating offsets from the size of FILE - not very
portable code) and used that for setvbuf. Can't one get stdin/stdout from
Input/Output? They refer to the same buffers after all. Anyway, it doesn't
seem to matter for my problem.

 > TProcess does not do any buffering. What is more, it's up to the called
 > application to decide whether it buffers it's output or not, and TProcess
 > does not have any control over that.

I had information claiming the contrary, that the caller can use setvbuf
to control the buffering, and then exec to the other program. However, my
attempts to do it are not successful so far, so I think you are quite right.

So I continue with pseudo-terminals. I found that the other day, and that
might help. I spent yesterday working on it and the tests look promising,
it might be the solution, at least for most Unixes.


/Ingemar

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal