File fbguard-allow-creating-a-guard-pidfile.patch of Package firebird
From: Michal Kubecek <mkubecek@suse.cz>
Date: Tue, 8 May 2012 21:13:41 +0200
Subject: fbguard: allow creating a guard pidfile
To better cooperate with killproc, add option -gpidfile to create
a pidfile with fbguard PID.
---
src/utilities/guard/guard.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
--- a/src/utilities/guard/guard.cpp
+++ b/src/utilities/guard/guard.cpp
@@ -91,6 +91,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
bool daemon = false;
const TEXT* prog_name = argv[0];
const TEXT* pidfilename = 0;
+ const TEXT* gpidfilename = 0;
int guard_exit_code = 0;
int timeout_term = 3;
@@ -120,6 +121,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
case 'T':
timeout_term = atoi(*argv++);
break;
+ case 'G':
+ gpidfilename = *argv++;
+ break;
default:
fprintf(stderr,
"Usage: %s [-signore | -onetime | -forever (default)] [-daemon] [-pidfile filename] "
@@ -218,6 +222,22 @@ int CLIB_ROUTINE main( int argc, char **argv)
}
}
+ if (gpidfilename)
+ {
+ FILE *gpf = fopen(gpidfilename, "w");
+ if (gpf)
+ {
+ unsigned guard_pid = getpid();
+ fprintf(gpf, "%d", guard_pid);
+ fclose(gpf);
+ }
+ else
+ {
+ gds__log("%s: guardian could not open %s for writing, error %d\n",
+ prog_name, gpidfilename, errno);
+ }
+ }
+
// wait for child to die, and evaluate exit status
bool shutdown_child = true;
if (!shutting_down)
@@ -288,6 +308,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
if (pidfilename) {
remove(pidfilename);
}
+ if (gpidfilename) {
+ remove(gpidfilename);
+ }
UTIL_ex_unlock(fd_guard);
exit(guard_exit_code);
} // main