Fix not closing files from /proc/ on read errors

The cmdline files opened from /proc/ were not closed if reading the data
from them failed (e.g. because the file was empty). This leaked the file
descriptor which could lead to failures trying to open more files later.
remotes/origin/falkon
Philipp Wiesemann 11 years ago
parent 8521b782bd
commit 3849fed838
  1. 4
      src/lib/3rdparty/processinfo.cpp

@ -85,12 +85,12 @@ pid_t ProcessInfo::GetPIDbyName(const char* cchrptr_ProcessName) const
if (fd_CmdLineFile) {
int r = fscanf(fd_CmdLineFile, "%20s", chrarry_NameOfProcess) ; // read from /proc/<NR>/cmdline
fclose(fd_CmdLineFile); // close the file prior to exiting the routine
if (r < 1) {
continue;
}
fclose(fd_CmdLineFile); // close the file prior to exiting the routine
if (strrchr(chrarry_NameOfProcess, '/')) {
chrptr_StringToCompare = strrchr(chrarry_NameOfProcess, '/') + 1 ;
}

Loading…
Cancel
Save