in reply to Threading read access to a filedescriptor

You probably don't want to be sharing the open filehandle between processes, since each process will be moving that filehandle around, and reading arbitrary bits of data.

Ignoring alternatives that force you to re-think your design fundamentally, I might suggest that you fork first, then open the file. Have each thread know how much of the file it's going to be reading, and what thread number it is, and then have it seek to the right spot in the file, find the next new line, and read until it passes the starting point for the next thread.

I have no idea how easy it will be to add all of this to the DBM file, though.

  • Comment on Re: Threading read access to a filedescriptor