From 752dae785bb7ab482603f56c1583d4c67b9dd68f Mon Sep 17 00:00:00 2001 From: Alaa Eddine Elamri Date: Tue, 21 Sep 2021 09:57:57 +0200 Subject: [PATCH] stored: only creating pidfile when path it is specified as parameter --- core/src/stored/stored.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/stored/stored.cc b/core/src/stored/stored.cc index 71b63216732..e9e62b4434c 100644 --- a/core/src/stored/stored.cc +++ b/core/src/stored/stored.cc @@ -96,8 +96,9 @@ static void usage() " -dt print timestamp in debug output\n" " -f run in foreground (for debugging)\n" " -g run as group \n" + " -k keep going despite I/O errors\n" " -m print kaboom output (for debugging)\n" - " -p proceed despite I/O errors\n" + " -p use as destination when creating pidfile\n" " -s no signals (for debugging)\n" " -t test - read configuration and exit\n" " -u run as user \n" @@ -129,6 +130,7 @@ int main(int argc, char* argv[]) pthread_t thid; char* uid = nullptr; char* gid = nullptr; + char* pidfile_path = nullptr; setlocale(LC_ALL, ""); tzset(); @@ -151,7 +153,7 @@ int main(int argc, char* argv[]) TAPE_BSIZE); } - while ((ch = getopt(argc, argv, "c:d:fg:mpstu:vx:z:?")) != -1) { + while ((ch = getopt(argc, argv, "c:d:fg:kmp:stu:vx:z:?")) != -1) { switch (ch) { case 'c': /* configuration file */ if (configfile != nullptr) { free(configfile); } @@ -179,10 +181,14 @@ int main(int argc, char* argv[]) prt_kaboom = true; break; - case 'p': /* proceed in spite of I/O errors */ + case 'k': /* proceed in spite of I/O errors */ forge_on = true; break; + case 'p': /* print kaboom output */ + pidfile_path = strdup(optarg); + break; + case 's': /* no signals */ no_signals = true; break; @@ -266,8 +272,10 @@ int main(int argc, char* argv[]) if (!foreground && !test_config) { if (daemon_start()) { - CreatePidFile(me->pid_directory, "bareos-sd", - GetFirstPortHostOrder(me->SDaddrs)); + if (pidfile_path) { + CreatePidFile(me->pid_directory, "bareos-sd", + GetFirstPortHostOrder(me->SDaddrs)); + } #if !defined(HAVE_WIN32) exit(0); #endif