Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Fopen fails, even when given full path

Name: Anonymous 2018-11-05 19:33

When could fopen("/full/path/to/file.ext", "rb"). The file is on system partition, yet sometimes fopen still returns 0. Why would it ever fail? Some async read-preventing locks by itself or external app, like antivirus scanner? How to find what app locked the file? These crashes are really annoying and make me paranoid.

Name: Anonymous 2018-11-05 19:41

Race condition with file access. Antivirus sounds plausible, maybe a memory rewrite because of page fault.

Name: Anonymous 2018-11-05 20:11

im in ur computer, readin ur filez

i can has deadlock?

Name: Clarence Darrow 2018-11-05 20:41

The witness will answer the question.

Name: Anonymous 2018-11-05 21:21

#include <errno.h>

Name: Anonymous 2018-11-05 21:50

dependent types would have prevented this

Name: Anonymous 2018-11-05 22:21

>>5
It says "Error: Too many open files".

But I close all my files!!! Probably some library routine does it.

Name: Anonymous 2018-11-05 22:22

>>1
Try using perror("Failed to open the file")/strerror(errno) to find the exact error next time.

by itself
That would make sense if you had used C11's e flag for fopen or something.

Anyway, as for your question: fuser /full/path/to/file.ext

>>6
Incorrect

Name: Anonymous 2018-11-05 22:47

>>7
Ok. It was indeed done by library.

Name: Anonymous 2018-11-05 22:47

>>9
debugged it using lsof -p $PID

Name: Anonymous 2018-11-05 23:22

nix* has many many archaic bugs have never been address to this day:
https://threadreaderapp.com/thread/1059306393885241346.html
"Everything is a File" had it's use. Now "Everything is addressable!" is where we are headed.

Don't change these.
Name: Email:
Entire Thread Thread List