From: Denis Kirjanov Date: Thu, 29 Feb 2024 12:26:34 +0000 (-0500) Subject: ifstat: handle unlink return value X-Git-Tag: v6.8.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67685422bfee1b886b907e03129b12c8a1ebb6a4;p=thirdparty%2Fiproute2.git ifstat: handle unlink return value Print an error message if we can't remove the history file v2: exit if unlink failed v3: restore the changelog Signed-off-by: Denis Kirjanov Signed-off-by: Stephen Hemminger --- diff --git a/misc/ifstat.c b/misc/ifstat.c index 767cedd4..72901097 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -937,8 +937,10 @@ int main(int argc, char *argv[]) "%s/.%s_ifstat.u%d", P_tmpdir, stats_type, getuid()); - if (reset_history) - unlink(hist_name); + if (reset_history && unlink(hist_name) < 0) { + perror("ifstat: unlink history file"); + exit(-1); + } if (!ignore_history || !no_update) { struct stat stb;