Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Handle EINTR in pkg_query_select.
Vsevolod Stakhov committed 11 years ago
commit 409f5258a282dd862c84d5675f1a8c378eff1831
parent c8dd4e0
1 file changed +9 -2
modified src/utils.c
@@ -182,7 +182,13 @@ query_select(const char *msg, const char **opts, int ncnt, int deft)
		}
	}

-
	getline(&str, &n, stdin);
+
	i = deft;
+
	while (getline(&str, &n, stdin) == -1) {
+
		if (errno == EINTR)
+
			continue;
+
		else
+
			goto cleanup;
+
	}
	i = (int) strtoul(str, &endpntr, 10);

	if (endpntr == NULL || *endpntr == '\0') {
@@ -193,8 +199,9 @@ query_select(const char *msg, const char **opts, int ncnt, int deft)
	} else
		i = -1;

+
cleanup:
	free(str);
-
	return i;
+
	return (i);
}

/* unlike realpath(3), this routine does not expand symbolic links */