From 7ecb880168d756e157c14094e4092cc4d37ae68a Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 9 Dec 2014 00:57:46 +0100 Subject: [PATCH] Only ignore sigpipe in interactive mode This allows shell pipes to correctly end redis-cli. Ref #2066 --- src/redis-cli.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 88ec90a2..d73d3739 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1916,8 +1916,6 @@ int main(int argc, char **argv) { argc -= firstarg; argv += firstarg; - signal(SIGPIPE, SIG_IGN); - /* Latency mode */ if (config.latency_mode) { if (cliConnect(0) == REDIS_ERR) exit(1); @@ -1966,6 +1964,9 @@ int main(int argc, char **argv) { /* Start interactive mode when no command is provided */ if (argc == 0 && !config.eval) { + /* Ignore SIGPIPE in interactive mode to force a reconnect */ + signal(SIGPIPE, SIG_IGN); + /* Note that in repl mode we don't abort on connection error. * A new attempt will be performed for every command send. */ cliConnect(0);