0b850e
diff -up nut-2.7.1/clients/upsmon.c.foreground nut-2.7.1/clients/upsmon.c
0b850e
--- nut-2.7.1/clients/upsmon.c.foreground	2013-07-26 21:41:10.000000000 +0200
0b850e
+++ nut-2.7.1/clients/upsmon.c	2014-02-27 11:39:58.158784578 +0100
0b850e
@@ -1645,6 +1645,7 @@ static void help(const char *progname)
324dac
 	printf("		 - reload: reread configuration\n");
324dac
 	printf("		 - stop: stop monitoring and exit\n");
324dac
 	printf("  -D		raise debugging level\n");
324dac
+	printf("  -F		run in foreground, do not daemonize\n");
324dac
 	printf("  -h		display this help\n");
324dac
 	printf("  -K		checks POWERDOWNFLAG, sets exit code to 0 if set\n");
324dac
 	printf("  -p		always run privileged (disable privileged parent)\n");
0b850e
@@ -1859,7 +1860,7 @@ static void check_parent(void)
324dac
 int main(int argc, char *argv[])  
324dac
 {
324dac
 	const char	*prog = xbasename(argv[0]);
324dac
-	int	i, cmd = 0, checking_flag = 0;
324dac
+	int	i, cmd = 0, checking_flag = 0, foreground = 0;
324dac
 
324dac
 	printf("Network UPS Tools %s %s\n", prog, UPS_VERSION);
324dac
 
0b850e
@@ -1870,7 +1871,7 @@ int main(int argc, char *argv[])
324dac
 
324dac
 	run_as_user = xstrdup(RUN_AS_USER);
324dac
 
324dac
-	while ((i = getopt(argc, argv, "+Dhic:f:pu:VK46")) != -1) {
324dac
+	while ((i = getopt(argc, argv, "+DFhic:f:pu:VK46")) != -1) {
324dac
 		switch (i) {
324dac
 			case 'c':
324dac
 				if (!strncmp(optarg, "fsd", strlen(optarg)))
0b850e
@@ -1887,6 +1888,9 @@ int main(int argc, char *argv[])
324dac
 			case 'D':
324dac
 				nut_debug_level++;
324dac
 				break;
324dac
+			case 'F':
324dac
+				foreground = 1;
324dac
+				break;
324dac
 			case 'f':
324dac
 				free(configfile);
324dac
 				configfile = xstrdup(optarg);
0b850e
@@ -1962,9 +1966,9 @@ int main(int argc, char *argv[])
324dac
 		exit(EXIT_FAILURE);
324dac
 	}
324dac
 
324dac
-	if (nut_debug_level < 1) {
324dac
+	if (!foreground && nut_debug_level < 1) {
324dac
 		background();
324dac
-	} else {
324dac
+	} else if (nut_debug_level >= 1) {
324dac
 		upsdebugx(1, "debug level is '%d'", nut_debug_level);
324dac
 	}
324dac
 	
0b850e
diff -up nut-2.7.1/scripts/systemd/nut-monitor.service.in.foreground nut-2.7.1/scripts/systemd/nut-monitor.service.in
0b850e
--- nut-2.7.1/scripts/systemd/nut-monitor.service.in.foreground	2014-02-27 11:39:58.141784438 +0100
0b850e
+++ nut-2.7.1/scripts/systemd/nut-monitor.service.in	2014-02-27 11:39:58.152784529 +0100
324dac
@@ -4,9 +4,8 @@ After=local-fs.target network.target nut
324dac
 
324dac
 [Service]
076835
 ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf
324dac
-ExecStart=@SBINDIR@/upsmon
324dac
-PIDFile=@PIDPATH@/upsmon.pid
324dac
-Type=forking
324dac
+ExecStart=@SBINDIR@/upsmon -F
324dac
+Type=simple
324dac
 
324dac
 [Install]
324dac
 WantedBy=multi-user.target
0b850e
diff -up nut-2.7.1/scripts/systemd/nut-server.service.in.foreground nut-2.7.1/scripts/systemd/nut-server.service.in
0b850e
--- nut-2.7.1/scripts/systemd/nut-server.service.in.foreground	2013-07-26 21:41:11.000000000 +0200
0b850e
+++ nut-2.7.1/scripts/systemd/nut-server.service.in	2014-02-27 11:39:58.152784529 +0100
324dac
@@ -5,8 +5,8 @@ Requires=nut-driver.service
324dac
 Before=nut-monitor.service
324dac
 
324dac
 [Service]
324dac
-ExecStart=@SBINDIR@/upsd 
324dac
-Type=forking
324dac
+ExecStart=@SBINDIR@/upsd -F
324dac
+Type=simple
324dac
 
324dac
 [Install]
324dac
 WantedBy=multi-user.target
0b850e
diff -up nut-2.7.1/server/upsd.c.foreground nut-2.7.1/server/upsd.c
0b850e
--- nut-2.7.1/server/upsd.c.foreground	2013-07-26 21:41:11.000000000 +0200
0b850e
+++ nut-2.7.1/server/upsd.c	2014-02-27 11:39:58.153784537 +0100
0b850e
@@ -827,6 +827,7 @@ static void help(const char *progname)
324dac
 	printf("		 - reload: reread configuration files\n");
324dac
 	printf("		 - stop: stop process and exit\n");
324dac
 	printf("  -D		raise debugging level\n");
324dac
+	printf("  -F		run in foreground, do not daemonize\n");
324dac
 	printf("  -h		display this help\n");
324dac
 	printf("  -r <dir>	chroots to <dir>\n");
324dac
 	printf("  -q		raise log level threshold\n");
0b850e
@@ -890,7 +891,7 @@ void check_perms(const char *fn)
324dac
 
324dac
 int main(int argc, char **argv)
324dac
 {
324dac
-	int	i, cmd = 0;
324dac
+	int	i, cmd = 0, foreground = 0;
324dac
 	char	*chroot_path = NULL;
324dac
 	const char	*user = RUN_AS_USER;
324dac
 	struct passwd	*new_uid = NULL;
0b850e
@@ -906,7 +907,7 @@ int main(int argc, char **argv)
324dac
 
324dac
 	printf("Network UPS Tools %s %s\n", progname, UPS_VERSION);
324dac
 
324dac
-	while ((i = getopt(argc, argv, "+h46p:qr:i:fu:Vc:D")) != -1) {
324dac
+	while ((i = getopt(argc, argv, "+hF46p:qr:i:fu:Vc:D")) != -1) {
324dac
 		switch (i) {
324dac
 			case 'h':
324dac
 				help(progname);
0b850e
@@ -944,6 +945,10 @@ int main(int argc, char **argv)
324dac
 				nut_debug_level++;
324dac
 				break;
324dac
 
324dac
+			case 'F':
324dac
+				foreground = 1;
324dac
+				break;
324dac
+
324dac
 			case '4':
324dac
 				opt_af = AF_INET;
324dac
 				break;
0b850e
@@ -1031,7 +1036,7 @@ int main(int argc, char **argv)
324dac
 	/* handle upsd.users */
324dac
 	user_load();
324dac
 
324dac
-	if (!nut_debug_level) {
324dac
+	if (!nut_debug_level && !foreground) {
324dac
 		background();
324dac
 		writepid(pidfn);
324dac
 	} else {