[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] popen()/pclose() and the pipes?



Hello!

> A long time age, I ask some question about inter-processus communication. All I
> wanted to do was to "pipe" some datas through several programs ("across" STDIN
> and STDOUT).
>
> What's these popen() and pclose()? These are no "standard" GEMDOS/MINT call but
> C stuff.

It's posix standard.

> Can somebody tell me how to replace popen()/pclose() with GEMDOS calls or, at
> least, where theses procedures are *really* defined in the MiNT sources or more
> likely in the GCC environment?

It's part of the MiNTLib, see stdio/popen.c. I don't think it match your
requirements if you only want to redirect stdin/stdout to a pipe.
popen/pclose open a new shell (/bin/sh) that stdin/stdout is connected to
the pipe returned by popen.

> And what are the limits of the pipes? What happens when a program wants to send
> MBytes of datas in a pipe if the receiver is just too slow to catch all this?
>
> Will the sender be "locked" until the receiver reads all that was already sent?
> Will datas be lost? Or what else? Will the whole pipe system explode?  ;-)

A pipe is nothing more as two filedeskriptors without a real file on your
harddisc. One filedeskriptor is connected to the read end, the other to
the write end. Also the filedeskriptors are handled as every other
filedeskriptor, there is no difference. If the filedeskriptor is in
blocking mode a read/write attempt with more bytes as the the pipe buffer
will block the application until enough space is available. In
non-blocking mode you get EAGAIN error instead. select/poll/fstat
work too like on every other filedeskriptor.

I can post some example code that directly use the system calls (there are
some differences to the MiNTLib posix functions; also the MiNTLib include
some workarounds for wrong kernel behaviour). You can ask Marc-Anton Kehr
or Ingo Schmidt too; they are both GFA coders and I posted both same
example code about usage of pipes. They translated that into working GFA
code as far as I know. Maybe a working GFA example is the best way for
you.


Tschuess
   ...Frank

--
ATARI FALCON 040 // MILAN 060
-----------------------------------------
http://www.cs.uni-magdeburg.de/~fnaumann/
e-Mail: fnaumann@freemint.de