I have a C program and a bash script that need exclusive access to a file. I've seen that you can use mkdir with bash, but does this mix well with C? Is it safe to just test the presence of a directory, create and then delete it?
What I'm actually doing: a C program keeps rewriting a file with new data that is then read from a bash script.
bash
script happens to be reading the file as you overwrite it, it will still be able to finish reading the file if it has it open. Then next time thebash
script opens the file, it will get the newly renamed one.