Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: ignore EINTR in ztcp/zsocket accept()



Interrupting `ztcp -a` causes zsh to exit immediately. Would it be
appropriate to just ignore EINTR?
/jsks

diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index cd56d46..92d0a50 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -191,8 +191,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
 	}
 
 	len = sizeof(soun);
-	if ((rfd = accept(lfd, (struct sockaddr *)&soun, &len)) == -1)
-	{
+	do {
+	    rfd = accept(lfd, (struct sockaddr *)&soun, &len);
+	} while (errno == EINTR && !errflag);
+
+	if (rfd == -1) {
 	    zwarnnam(nam, "could not accept connection: %e", errno);
 	    return 1;
 	}
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index d5b62a8..3049273 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -536,8 +536,11 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
 	sess = zts_alloc(ZTCP_INBOUND);
 
 	len = sizeof(sess->peer.in);
-	if ((rfd = accept(lfd, (struct sockaddr *)&sess->peer.in, &len)) == -1)
-	{
+	do {
+	    rfd = accept(lfd, (struct sockaddr *)&sess->peer.in, &len);
+	} while (errno == EINTR && !errflag);
+
+	if (rfd == -1) {
 	    zwarnnam(nam, "could not accept connection: %e", errno);
 	    tcp_close(sess);
 	    return 1;



Messages sorted by: Reverse Date, Date, Thread, Author