X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=7f91dcb8151ea6ae6083668e78df123f73521758;hb=208ff148af91eb5ee6b2d88ada757c27be24d443;hp=365510b3c37de51bacdeafee888b7f87e9776ac5;hpb=d9dbcf5efef2ff10ebb89d0272af4a76a7141a58;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 365510b3c..7f91dcb81 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -477,10 +477,14 @@ int utils_create_pid_file(pid_t pid, const char *filepath) ret = fprintf(fp, "%d\n", pid); if (ret < 0) { PERROR("fprintf pid file"); + goto error; } - fclose(fp); + if (fclose(fp)) { + PERROR("fclose"); + } DBG("Pid %d written in file %s", pid, filepath); + ret = 0; error: return ret; } @@ -512,9 +516,11 @@ int utils_create_lock_file(const char *filepath) */ ret = flock(fd, LOCK_EX | LOCK_NB); if (ret) { - WARN("Could not get lock file %s, another instance is running.", + ERR("Could not get lock file %s, another instance is running.", filepath); - close(fd); + if (close(fd)) { + PERROR("close lock file"); + } fd = ret; goto error; }