From: Joshua Krusell <js.shirin@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: ignore EINTR in ztcp/zsocket accept()
Date: Mon, 10 Aug 2015 12:22:12 +0200 [thread overview]
Message-ID: <20150810102212.GA45526@Qliphoth.local> (raw)
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;
next reply other threads:[~2015-08-10 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 10:22 Joshua Krusell [this message]
2015-08-10 11:33 ` Peter Stephenson
2015-08-10 12:18 ` Oliver Kiddle
2015-08-10 12:31 ` Peter Stephenson
2015-08-10 14:30 ` Joshua Krusell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150810102212.GA45526@Qliphoth.local \
--to=js.shirin@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).