nmh-workers
[Top] [All Lists]

Re: [nmh-workers] closefds() _before_ fork?

2019-04-25 15:53:48
Basically, it opens a file and  attempts to obtain an exclusive lock the
file  descriptor for  that  file. If/when  it  successfully obtains  the
exclusive lock  it then uses exec()  to execute a new  process, and that
new process inherits  the open file descriptor. As long  as that process
leaves the file  descriptor open, it continues to hold  the lock on said
file  which  prevents  any  similarly  invoked  processes  from  running
concurrently.

The  lock goes  away either  when the  file descriptor  is intentionally
closed, or the process exits or crashes.

Ah, alright, I see how that works.  And yes, as you note later on, this
should actually be an improvement over current nmh behavior, at least
in relation to programs that want to do this sort of thing.

Yes, I see  what you mean---also, I didn't realize  that the approach in
nmh was so  varied, but then, I haven't looked  at the sources in-depth.

Yeah, consistency is not an nmh (nor MH) hallmark, sadly :-)

--Ken

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>