diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-11-20 14:05:22 +1300 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-11-20 14:11:34 +1300 |
commit | c239a8bf0767a31ca87d3d3cecc3006789992753 (patch) | |
tree | d0c408050ebbfc6bf000b66974291be6ab79eab7 | |
parent | c9265161f88c5a602fdd56131334e492ff18dcc7 (diff) | |
download | paramano-c239a8bf0767a31ca87d3d3cecc3006789992753.tar.xz |
Fixed hanging fd on battery status read failure
-rw-r--r-- | bat_tray.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -235,10 +235,15 @@ int get_battery_state() char state[1024]; FILE* fd = NULL; - if (!(fd = fopen(CHARGE_STATE_PATH, "r")) || - !fgets(state, sizeof(state), fd)) + if (!(fd = fopen(CHARGE_STATE_PATH, "r"))) return STATE_UNKNOWN; + if (!fgets(state, sizeof(state), fd)) + { + fclose(fd); + return STATE_UNKNOWN; + } + fclose(fd); chomp(state); |