Hi, sorry I didn't attach any reference code. it just does fopen and fscanf on the /sys... file , the application code looks similar to this...
int getsensortemps()
{
FILE* tempfile = NULL;
int *tempvalue = 0;
tempfile = fopen("/sys/class/hwmon/hwmon0/temp1_input", "r");
if( tempfile == NULL )return -1;
if(fscanf(tempfile, "%d" ,tempvalue) > 0){
*tempvalue=*tempvalue / 100;
fclose(tempfile);
return *tempvalue;
}
fclose(tempfile);
return -1
}
my problem is multiple process access this function
1) A background process which updates temp periodically
2) A CLI command which gives temp output
both access this function, and sometimes this causes crash with no logs. I even tried cat /sys/class/hwmon/hwmon0/temp1_input this also produced crash. The crash is not certain to happen but occurs randomly , with probability increasing with how fast we access the /sys/.... file...
the lm75 sensor code is generic one..
thanks in advance
https://elixir.bootlin.com/linux/lat...s/hwmon/lm75.c