diff contrib/chg/chg.c @ 28516:3bf2892f685f

chgserver: handle ParseError during validate Currently the validate command in chgserver expects config can be loaded without issues but the config can be broken and chg will print a stacktrace instead of the parsing error, if a chg server is already running. This patch adds a handler for ParseError in validate and a new instruction "exit" to make the client exit without abortmsg. A test is also added to make sure it will behave as expected.
author Jun Wu <quark@fb.com>
date Mon, 14 Mar 2016 12:52:35 +0000
parents 194a6cd873cd
children aa082a8125da
line wrap: on
line diff
--- a/contrib/chg/chg.c	Mon Mar 14 12:32:09 2016 +0000
+++ b/contrib/chg/chg.c	Mon Mar 14 12:52:35 2016 +0000
@@ -460,6 +460,11 @@
 					 "%s", *pinst + 9);
 			if (r < 0 || r >= (int)sizeof(opts->redirectsockname))
 				abortmsg("redirect path is too long (%d)", r);
+		} else if (strncmp(*pinst, "exit ", 5) == 0) {
+			int n = 0;
+			if (sscanf(*pinst + 5, "%d", &n) != 1)
+				abortmsg("cannot read the exit code");
+			exit(n);
 		} else {
 			abortmsg("unknown instruction: %s", *pinst);
 		}