Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > by-pkgid > 4c8ea00889f908c00ccba3a48b9c2ade > files > 10

mdadm-2.6.9-2mnb2.src.rpm

--- 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;
 }