simple_ctrl.c: Support an indefinite timeout (using tout_msec=0)
diff --git a/simple_ctrl.c b/simple_ctrl.c
index 1d3b250..2290785 100644
--- a/simple_ctrl.c
+++ b/simple_ctrl.c
@@ -48,10 +48,12 @@
 
 	FD_ZERO(&readset);
 	FD_SET(fd, &readset);
-	tout.tv_sec = tout_msec/1000;
-	tout.tv_usec = (tout_msec%1000)*1000;
+	if (tout_msec) {
+		tout.tv_sec = tout_msec/1000;
+		tout.tv_usec = (tout_msec%1000)*1000;
+	}
 
-	rc = select(fd+1, &readset, NULL, NULL, &tout);
+	rc = select(fd+1, &readset, NULL, NULL, tout_msec ? &tout : NULL);
 	if (rc < 0)
 		return rc;
 
@@ -69,10 +71,12 @@
 
 	FD_ZERO(&writeset);
 	FD_SET(fd, &writeset);
-	tout.tv_sec = tout_msec/1000;
-	tout.tv_usec = (tout_msec%1000)*1000;
+	if (tout_msec) {
+		tout.tv_sec = tout_msec/1000;
+		tout.tv_usec = (tout_msec%1000)*1000;
+	}
 
-	rc = select(fd+1, NULL, &writeset, NULL, &tout);
+	rc = select(fd+1, NULL, &writeset, NULL, tout_msec ? &tout : NULL);
 	if (rc < 0)
 		return rc;