From 205d7c3b23d6ee7d9f0993e465e4ab9c30a261fc Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Mon, 23 Feb 2009 22:41:36 +1300 Subject: [PATCH] Author: Mark Nottingham Bug 2599: Idempotent start As discussed on squid-dev, Squid shouldn't return a shell error when: - starting squid, if it's already running - stopping squid, if it isn't running This is to make writing scripts that control squid easier. Note that it should still notify the user, and should not affect other operations (e.g., kill, rotate, parse). --- src/main.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index ea43f2fec8..761b9f7a98 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1240,7 +1240,7 @@ SquidMain(int argc, char **argv) setUmask(Config.umask); if (-1 == opt_send_signal) if (checkRunningPid()) - exit(1); + exit(0); #if TEST_ACCESS @@ -1396,8 +1396,13 @@ sendSignal(void) exit(1); } } else { - fprintf(stderr, "%s: ERROR: No running copy\n", APP_SHORTNAME); - exit(1); + if (opt_send_signal != SIGTERM) { + fprintf(stderr, "%s: ERROR: No running copy\n", appname); + exit(1); + } else { + fprintf(stderr, "%s: No running copy\n", appname); + exit(0); + } } /* signal successfully sent */ -- 2.47.2