On Fri, 7 Jun 2019 12:13:13 +0200 Matteo Croce <mcr...@redhat.com> wrote:
> +void netns_restore(void) > +{ > + if (saved_netns != -1) { If saved_netns is -1 then it is a program bug becase no save was done? then do something? > + if (!setns(saved_netns, CLONE_NEWNET)) { > + close(saved_netns); > + saved_netns = -1; > + } else { > + perror("setns"); If you are going to look for errors. then you need to either return the error or cause the program to exit. You don't want later commands in the batch to be applied to wrong namespace.