Closing files after fork

2021-08-24 Thread Hal Murray via devel
> Can somebody give me a lesson in why a program should close all it's > descriptors? We can clean up a lot of crufty code if we drop that. Nobody responded to my request, so I'll assume it isn't needed and start working on deleting it. In hindsight, I'm surprised that Eric didn't remove it a

RE: Closing files after fork

2021-08-25 Thread Matt Selsky via devel
> Nobody responded to my request, so I'll assume it isn't needed and start working on deleting it. > In hindsight, I'm surprised that Eric didn't remove it ages ago. (Or add a comment about why it is necessary.) Hi Hal, I think we close all FDs in order to reduce the number of FDs open with our

Re: Closing files after fork

2021-08-25 Thread Hal Murray via devel
Matt Selsky said: > I think we close all FDs in order to reduce the number of FDs open with our > old security context. Eg, if we seteuid() after fork, we want to drop all FDs > opened with root privileges. That would make sense if we were talking about some big complicated program with lots o

Re: Closing files after fork

2021-08-25 Thread ASSI via devel
Hal Murray via devel writes: >> Can somebody give me a lesson in why a program should close all it's >> descriptors? We can clean up a lot of crufty code if we drop that. > > Nobody responded to my request, so I'll assume it isn't needed and start > working on deleting it. You're getting ahead o

Re: Closing files after fork

2021-08-26 Thread Hal Murray via devel
Thanks. > It isn't hard to put your question into a search and get useful answers as to > why this is a good practise (and also why it's crufty if you have to support > more than just Linux or any other single system). I poked around a bit and didn't find anything useful. I found a web page tha

Re: Closing files after fork

2021-08-26 Thread Achim Gratz via devel
Hal Murray via devel writes: > The close-everything code either has to skip the files it needs or > reopen them. That requires keeping track of the files it needs which > isn't something most programmers do. In our case, that was buggy. This is a general thing you have to do do in a daemon that