From b5e64645037e99b5f05c9499b27b422ae60d23a9 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 1 Nov 2004 04:49:34 +0000 Subject: mdadm-1.8.0 --- Monitor.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Monitor.c') 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; } -- cgit