Merge pull request #159 from 4zv4l/check_openFile
check open file before close() for host_model_info
This commit is contained in:
commit
e941d81815
1 changed files with 5 additions and 4 deletions
|
@ -666,9 +666,10 @@ void get_info()
|
|||
#else
|
||||
FILE *cpuinfo = popen("sysctl -a | egrep -i 'hw.model'", "r");
|
||||
#endif
|
||||
FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
|
||||
if (!host_model_info)
|
||||
if ((host_model_info = fopen("/sys/devices/virtual/dmi/id/product_name", "r")) != NULL)
|
||||
FILE *host_model_info = fopen("/sys/devices/virtual/dmi/id/board_name", "r"); // first try open the file
|
||||
if (!host_model_info) // if failed
|
||||
host_model_info = fopen("/sys/devices/virtual/dmi/id/product_name", "r"); // try open another file
|
||||
if(host_model_info) // if one of the file could be open then close it
|
||||
fclose(host_model_info);
|
||||
#ifdef __WINDOWS__
|
||||
host_model_info = popen("wmic computersystem get model", "r");
|
||||
|
|
Loading…
Reference in a new issue