You could use OpenFile(filename, O_RDONLY|O_EXCL, 0) on linux at least - this will only work if your process gets exclusive access to the file. If some other process still has the file open, it will fail.
The other option is: have your process create the files with a special filename and rename them, once all data has been written to them and closed the file. e.g. create it as ."filename.tmp" and rename later to "filename". your 2nd process would need to be careful to ignore all files starting e.g. a dot, or ending in ".tmp".
Or use different directories instad of filename extensions:creating the files use a different directory and move the file around once it has written all data and closed the file. For example:
base/tmp <- create new files here, put data in them, close them
base/new <- move file here so for the next process to pick up the file
base/tmp <- 2nd process can move the file around again as a sign of "I', working on this file and handling it"
base/done <- if you process files as a one shot, move them again to a differnt special directory
base/failed <- I often preferr to sort out files that couldn't be processed
Such a schema works only well, if all your filenames are unique. Otherwise you could end up creating the same file
in several steps, and moving the file around would overwrite other files.
Regards, Andreas