contrib/chg/chg.c
changeset 29345 62b890496de5
parent 29344 bb3d5c20eaf6
child 29357 66d41c9e9222
--- a/contrib/chg/chg.c	Sat Jun 11 20:25:49 2016 +0100
+++ b/contrib/chg/chg.c	Mon Jun 13 21:30:14 2016 +0100
@@ -249,7 +249,13 @@
 	int pst = 0;
 
 	debugmsg("try connect to %s repeatedly", opts->sockname);
-	for (unsigned int i = 0; i < 10 * 100; i++) {
+
+	unsigned int timeoutsec = 10;  /* default: 10 seconds */
+	const char *timeoutenv = getenv("CHGTIMEOUT");
+	if (timeoutenv)
+		sscanf(timeoutenv, "%u", &timeoutsec);
+
+	for (unsigned int i = 0; !timeoutsec || i < timeoutsec * 100; i++) {
 		hgclient_t *hgc = hgc_open(opts->sockname);
 		if (hgc)
 			return hgc;