[PATCH 1 of 2] chg: server exited with code 0 without being connectable is an error

Jun Wu quark at fb.com
Sun Apr 10 23:56:58 UTC 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1460322034 -3600
#      Sun Apr 10 22:00:34 2016 +0100
# Node ID 20ad199286a5f70d46ac4818dfa681327385d5a3
# Parent  99a2bdad0fda4fe16830376ad81c1065a5080cb9
chg: server exited with code 0 without being connectable is an error

Before this patch, if the server started by chg has exited with code 0 without
creating a connectable unix domain socket at the specified address, chg will
exit with code 0, which is not the correct behavior. It can happen, for
example, CHGHG is set to /bin/true.

This patch addresses the issue by checking the exit code of the server and
print a new error message if the server exited normally but cannot be
connected.

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -261,6 +261,9 @@
 
 cleanup:
 	if (WIFEXITED(pst)) {
+		if (WEXITSTATUS(pst) == 0)
+			abortmsg("cmdserver exited normally "
+				 "but cannot be connected");
 		debugmsg("cmdserver exited with status %d", WEXITSTATUS(pst));
 		exit(WEXITSTATUS(pst));
 	} else if (WIFSIGNALED(pst)) {


More information about the Mercurial-devel mailing list