[fpc-pascal] Problem with file descriptors when doing fork on linux

Michael Van Canneyt michael at freepascal.org
Fri Feb 2 11:33:46 CET 2018



On Fri, 2 Feb 2018, Ko Paka wrote:

> Hello,
>
> I would like to ask advice. My colleague run into a problem, when he had
> used TProcess to spawn other process. Because of fork nature, file
> descriptors was copied into newly created process.
> He found that for such cases CLOEXEC flag exists to be used when open file.
> I found flag declared in various units inside fpc, but nowhere to be used.
> So when I need to use it I need to make some own routine?

I have added it to the linux unit:

Const
   O_CLOEXEC = $80000;

If you want to use it today, you'll need to add it to your own units
manually.

> Or more generally do exists in fpc some other way how to deal with this
> problem - to create new process but without copied file descriptors?

No, currently not.

Michael.



More information about the fpc-pascal mailing list