Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-02

Problem with file descriptors when doing fork on linux

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ko Paka

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? 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?

tomas

Reply by email

Michael Van Canneyt
to Ko Paka
Ko Paka wrote 8 lines
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.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 02/02/18 a les 11:33, Michael Van Canneyt ha escrit:

Show quoted text 5 lines
> 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.

Why doesn't the unix implementation take into account the InheritHandles property?

Bye

Luca

Reply by email