From 9e03bf9f1ecd4b392e0dfd74cfba1d8b7313ddd6 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 23 May 2022 15:42:21 +0200 Subject: [PATCH] bind: Return different error if accept was interrupted Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/13 Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/bind.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bind.c b/src/bind.c index 6e1a926d..5a71244d 100644 --- a/src/bind.c +++ b/src/bind.c @@ -586,9 +586,15 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) fd = accept(sshbind->bindfd, NULL, NULL); if (fd == SSH_INVALID_SOCKET) { - ssh_set_error(sshbind, SSH_FATAL, - "Accepting a new connection: %s", - strerror(errno)); + if (errno == EINTR) { + ssh_set_error(sshbind, SSH_EINTR, + "Accepting a new connection (child signal error): %s", + strerror(errno)); + } else { + ssh_set_error(sshbind, SSH_FATAL, + "Accepting a new connection: %s", + strerror(errno)); + } return SSH_ERROR; } rc = ssh_bind_accept_fd(sshbind, session, fd);