summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2004-11-01 04:49:34 +0000
committerNeil Brown <neilb@suse.de>2004-11-01 04:49:34 +0000
commitb5e64645037e99b5f05c9499b27b422ae60d23a9 (patch)
treef0999c8649d1488a367ee3d9442aff538ae366a8 /Monitor.c
parente5329c3747a4e9eb7addbfaa59b8d5e8688ce2a1 (diff)
downloadmdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.tar.gz
mdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.tar.xz
mdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.zip
mdadm-1.8.0mdadm-1.8.0
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Monitor.c b/Monitor.c
index ce0087c..036c47f 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -47,7 +47,7 @@ static char *percentalerts[] = {
int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- char *config, int test)
+ char *config, int test, char* pidfile)
{
/*
* Every few seconds, scan every md device looking for changes
@@ -127,7 +127,18 @@ int Monitor(mddev_dev_t devlist,
if (daemonise) {
int pid = fork();
if (pid > 0) {
- printf("%d\n", pid);
+ if (!pidfile)
+ printf("%d\n", pid);
+ else {
+ FILE *pid_file;
+ pid_file=fopen(pidfile, "w");
+ if (!pid_file)
+ perror("cannot create pid file");
+ else {
+ fprintf(pid_file,"%d\n", pid);
+ fclose(pid_file);
+ }
+ }
return 0;
}
if (pid < 0) {
@@ -428,6 +439,8 @@ int Monitor(mddev_dev_t devlist,
}
test = 0;
}
+ if (pidfile)
+ unlink(pidfile);
return 0;
}