In some cases passing file to monitor left file open.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
}
if (file) {
FILE *fp;
+ int err;
+
fp = fopen(file, "r");
if (fp == NULL) {
perror("Cannot fopen");
exit(-1);
}
- return rtnl_from_file(fp, accept_msg, stdout);
+ err = rtnl_from_file(fp, accept_msg, stdout);
+ fclose(fp);
+ return err;
}
if (rtnl_open(&rth, groups) < 0)
if (file) {
FILE *fp;
+ int err;
+
fp = fopen(file, "r");
if (fp == NULL) {
perror("Cannot fopen");
exit(-1);
}
- return rtnl_from_file(fp, xfrm_accept_msg, (void*)stdout);
+ err = rtnl_from_file(fp, xfrm_accept_msg, stdout);
+ fclose(fp);
+ return err;
}
if (rtnl_open_byproto(&rth, groups, NETLINK_XFRM) < 0)
}
if (file) {
- FILE *fp;
- fp = fopen(file, "r");
+ FILE *fp = fopen(file, "r");
+ int ret;
+
if (fp == NULL) {
perror("Cannot fopen");
exit(-1);
}
- return rtnl_from_file(fp, accept_tcmsg, (void*)stdout);
+
+ ret = rtnl_from_file(fp, accept_tcmsg, stdout);
+ fclose(fp);
+ return ret;
}
if (rtnl_open(&rth, groups) < 0)