From cafb98bea6c0ca9fb000aeb07feb4744d78c2ae5 Mon Sep 17 00:00:00 2001 From: geommer Date: Mon, 18 Apr 2016 17:30:29 +0200 Subject: [PATCH] close potential opened files before intern blk thread exist --- src/intern_blks/ya_intern.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/intern_blks/ya_intern.c b/src/intern_blks/ya_intern.c index 34fe507..deb40c9 100644 --- a/src/intern_blks/ya_intern.c +++ b/src/intern_blks/ya_intern.c @@ -231,6 +231,11 @@ void ya_int_bandwidth(ya_block_t * blk) { fprintf(stderr, "Error opening file %s or %s\n", rxpath, txpath); strncpy(blk->buf, "BLOCK ERROR!", strlen("BLOCK ERROR!")); ya_draw_pango_text(blk); + //Close if one of the files is opened + if(rxfile) + fclose(rxfile); + if(txfile) + fclose(txfile); pthread_detach(blk->thread); pthread_exit(NULL); } @@ -454,6 +459,11 @@ void ya_int_battery(ya_block_t *blk) { fprintf(stderr, "Error opening file %s or %s\n", cpath, spath); strncpy(blk->buf, "BLOCK ERROR!", strlen("BLOCK ERROR!")); ya_draw_pango_text(blk); + //Close if one of the files is opened + if(cfile) + fclose(cfile); + if(sfile) + fclose(sfile); pthread_detach(blk->thread); pthread_exit(NULL); }