]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Exit with first received error code when forking 13004/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 27 Feb 2023 23:28:59 +0000 (18:28 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 28 Mar 2023 14:10:33 +0000 (10:10 -0400)
vtysh -f forks.  Gather the return codes and report the first
failed return code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
vtysh/vtysh_config.c

index 0a0c745fda12985413e91b7a96d42cd58f653708..2949faa4275bc1527c6682d6d9cd3c1faef2749f 100644 (file)
@@ -682,11 +682,21 @@ int vtysh_apply_config(const char *config_file_path, bool dry_run, bool do_fork)
 
                /* parent, wait for children */
                if (fork_pid != 0) {
+                       int keep_status = 0;
+
                        fprintf(stdout,
                                "Waiting for children to finish applying config...\n");
-                       while (wait(&status) > 0)
-                               ;
-                       return 0;
+                       while (wait(&status) > 0) {
+                               if (!keep_status && WEXITSTATUS(status))
+                                       keep_status = WEXITSTATUS(status);
+                       }
+
+                       /*
+                        * This will return the first status received
+                        * that failed( if that happens ).  This is
+                        * good enough for the moment
+                        */
+                       return keep_status;
                }
 
                /*