"Ion GaztaƱaga"
No, it's not portable. I think you should use file locks which are automatically unlocked when a process dies. However, take in care that to achieve portable file locks you have several restrictions that I think you can avoid in your case:
I've been trying an approach using file locks, and, as you say, the lock will be released should the process die. However, other issues arise as regards cleaning up the file used for the lock: who creates it, and who deletes it? Clearly, for the creation case, the file could be created if it didn't exist - though there's a potential race condition. The deletion case is also tricky: a process figures out it is the only one (by getting the exclusive file lock) and then deletes the file (under Windows this will 'mark' the file for deletion when the last handle is released, i.e. the file lock). Before the file 'truly' disappears, another process starts up and attempts to get a shared lock on the file...this will fail (certainly on Windows). I could just leave the file around, but it's not very clean. Is there another approach?