Re: POpen en PClose
Michael Van Canneyt via fpc-pascal <[email protected]> Tue, 21 Jul 2026 08:11:44 +0200 (CEST)
| Newsgroups | gmane.comp.compilers.free-pascal.general |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1432349963-1784614305=:189307 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Tue, 21 Jul 2026, Adriaan van Os via fpc-pascal wrote: > > > On 20/07/2026 12:02, Marco van de Voort via fpc-pascal wrote: >> >> Op 20-7-2026 om 11:57 schreef Michael Van Canneyt via fpc-pascal: >>>>> >>>>> I am looking at the implementation of POpen and PClose in the >>>>> runtime-library for Darwin (or more general for UNIX). It seems >>>>> like it doesn't call into libc popen and pclose, but instead >>>>> follows its own implementation in unix.pp in POpen_internal. I am >>>>> just curious to know the reason. >>>>> >>>> Phew, that was over twenty years ago, but afaik the reason is that >>>> libc popen and pclose us C FILE descriptors, which the RTL in >>>> general doesn't use to avoid a mix of functions with pascal and C >>>> file types. >>>> >>>> So popen/pclose are a more high level (FILE * using) part of libc, >>>> while we tend to only use the basis. >>> >>> Glad our memories agree on this :-) >> >> Well aside from the fact that FreeBSD was the architecture where the >> baseunix/unix RTL was done. The port to Linux was only done later :-) >> >> This shows the tension a bit between libc the system lib, and libc the >> C runtime. We are only interested in the system lib part. > > Another question. POpen has a file as input parameter. The description > in unix.pp says > > "Starts the program in 'Prog' and makes it's input or out put the > other end of a pipe. If rw is 'w' or 'W', then whatever is written to > F, will be read from stdin by the program in 'Prog'. The inverse is true > for 'r' or 'R' : whatever the program in 'Prog' writes to stdout, can be > read from 'f'." > > So, for write mode, it doesn't use StdOut but a file. Does this imply > that (for writing) I can call POpen with multiple files, forking and > running multiple programs, writing to each of these child processes > through a different pipe ? If your question is, can you use POpen multiple times, then the answer is yes. Michael. --8323329-1432349963-1784614305=:189307 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ fpc-pascal maillist - [email protected] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal --8323329-1432349963-1784614305=:189307--