*/
/*
- * shar.cpp -- the SHAR "main" code. All the functionality is elsewhere
- * (in case you want to turn this into a library later).
+ * shar.cpp -- the shibd "main" code. All the functionality is elsewhere
*
* Created By: Derek Atkins <derek@ihtfp.com>
*
const char* shar_schemadir = NULL;
bool shar_checkonly = false;
static int unlink_socket = 0;
+const char* pidfile = NULL;
static bool new_connection(IListener::ShibSocket& listener, const Iterator<ShibRPCProtocols>& protos)
{
fprintf(stderr, " -d\tschema directory to use.\n");
fprintf(stderr, " -t\tcheck configuration file for problems.\n");
fprintf(stderr, " -f\tforce removal of listener socket.\n");
+ fprintf(stderr, " -p\tpid file to use.\n");
fprintf(stderr, " -h\tprint this help message.\n");
exit(1);
}
{
int opt;
- while ((opt = getopt(argc, argv, "c:d:fth")) > 0) {
+ while ((opt = getopt(argc, argv, "c:d:p:fth")) > 0) {
switch (opt) {
case 'c':
shar_config=optarg;
case 't':
shar_checkonly=true;
break;
+ case 'p':
+ pidfile=optarg;
+ break;
default:
return -1;
}
conf.shutdown();
return -5;
}
+
+ // Write the pid file
+ if (pidfile) {
+ FILE* pidf = fopen(pidfile, "w");
+ if (pidf) {
+ fprintf(pidf, "%d\n", getpid());
+ fclose(pidf);
+ } else {
+ perror(pidfile); // keep running though
+ }
+ }
// Initialize the SHAR Utilitites
SHARUtils::init();
}
conf.shutdown();
+ if (pidfile)
+ unlink(pidfile);
fprintf(stderr, "shibd shutdown complete\n");
return 0;
}