--- mdmpd/mdmpd.c.pid 2004-04-23 00:02:29.000000000 +0200 +++ mdmpd/mdmpd.c 2004-08-25 08:22:23.809863918 +0200 @@ -35,6 +35,7 @@ #include <string.h> #include <unistd.h> #include <pthread.h> +#include <paths.h> #include <mdstat.h> #include <mdctrl.h> @@ -205,6 +206,7 @@ { pthread_t recover_arrays_thread; struct sigaction action; + FILE *pid_file; (void) license; @@ -236,6 +238,15 @@ return -1; } + pid_file=fopen(_PATH_VARRUN "/mdmpd.pid", "w"); + + if (!pid_file) { + ERR("Failed to create pid file (errno=%d).\n", errno); + } else { + fprintf(pid_file,"%d\n", getpid()); + fclose(pid_file); + } + action.sa_handler = sighandler; sigaction(SIGHUP, &action, NULL); sigaction(SIGINT, &action, NULL); @@ -261,6 +272,7 @@ DBG("Ending mdstat monitor\n"); mdstat_unregister(); + unlink(_PATH_VARRUN "/mdmpd.pid"); return 0; }