Skip to content

Commit

Permalink
stored: only creating pidfile when path it is specified as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri committed Sep 21, 2021
1 parent 419c8a4 commit 752dae7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/src/stored/stored.cc
Expand Up @@ -96,8 +96,9 @@ static void usage()
" -dt print timestamp in debug output\n"
" -f run in foreground (for debugging)\n"
" -g <group> run as group <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 <path> use <path> as destination when creating pidfile\n"
" -s no signals (for debugging)\n"
" -t test - read configuration and exit\n"
" -u <user> run as user <user>\n"
Expand Down Expand Up @@ -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();
Expand All @@ -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); }
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 752dae7

Please sign in to comment.