3 ms·
Yeah. So I understand it has been considered best practice to check the file before opening it? Does that mean we can assume that most well-written programs wil
by afandian 6y ago
Yeah. So I understand it has been considered best practice to check the file before opening it? Does that mean we can assume that most well-written programs will follow the pattern and break on mac os?
I would have thought that even if Apple did make this change they could trap the fopen or whatever and return something useful based on a heuristic? It wouldn't be the first time that they put exceptions and heuristics in for software compatibility.
- chrisseaton 6y ago> So I understand it has been considered best practice to check the file before opening it? Check it... for what?
- coldtea 6y agoFor presence...
- chrisseaton 6y agoWhy do you need to separately check for presence before you use dlopen? If it's not there dlopen will give you a nice error message - no need to check yourself. Are you currently checking files are there before you dlopen them? How do you avoid a race between the stat and the dlopen? What happens if the file is removed between them? Seems broken and you shouldn't be doing this in the first place.
- zaarn 6y agoIt is usually unlikely that a file will be removed between stat and dlopen, such errors occur rarely. Even more rarely when the file happens to be a systems lib or plugin lib. Some errors occur rarely enough that it isn't worth worrying about.
- unilynx 6y agoIt has never been good practice to check before open - open first, then check. And if you're creating a file, use exclusive mode, don't check first. You're opening yourself up to a lot of race conditions otherwise, and this has been the source of many security vulnerabilities