ctrl: Fix fd leak in ctrl_listen()

Use the same pattern for handling rtnl_listen() errors that
is used across other iproute2 commands. All other commands
exit with status of 2 if rtnl_listen fails.

Reported-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Maks Mishin 2024-02-07 02:54:16 +03:00 committed by Stephen Hemminger
parent 35c0215739
commit f4dc6a784f

View File

@ -334,8 +334,9 @@ static int ctrl_listen(int argc, char **argv)
}
if (rtnl_listen(&rth, print_ctrl, (void *) stdout) < 0)
return -1;
exit(2);
rtnl_close(&rth);
return 0;
}