I have few processes running from root user. This processes all try to edit a file named file.php. I need to lock the file that only one process can write on it at a time. Is there anyway to do that? maybe SELinux works? I tried locking it using flock but it didn't work! It was the code I used:
exec 3>file.php
flock -x 3