--- a/minissdpd.c
+++ b/minissdpd.c
@@ -1251,6 +1251,7 @@
 	const char * pidfilename = "/var/run/minissdpd.pid";
 #endif
 	int debug_flag = 0;
+	int foreground_flag = 0;
 #ifdef ENABLE_IPV6
 	int ipv6 = 0;
 #endif /* ENABLE_IPV6 */
@@ -1285,6 +1286,9 @@
 		case 'd':
 			debug_flag = 1;
 			break;
+		case 'D':
+			foreground_flag = 1;
+			break;
 #ifdef ENABLE_IPV6
 		case '6':
 			ipv6 = 1;
@@ -1453,7 +1457,7 @@
 
 #ifndef NO_BACKGROUND_NO_PIDFILE
 	/* daemonize or in any case get pid ! */
-	if(debug_flag)
+	if(debug_flag || foreground_flag)
 		pid = getpid();
 	else {
 #ifdef USE_DAEMON
