diff --git minissdpd.c minissdpd.c
index 6295af9..39dddb6 100644
--- a/minissdpd.c
+++ b/minissdpd.c
@@ -1066,6 +1066,7 @@ int main(int argc, char * * argv)
 	const char * sockpath = "/var/run/minissdpd.sock";
 	const char * pidfilename = "/var/run/minissdpd.pid";
 	int debug_flag = 0;
+	int foreground_flag = 0;
 #ifdef ENABLE_IPV6
 	int ipv6 = 0;
 #endif /* ENABLE_IPV6 */
@@ -1086,6 +1087,8 @@ int main(int argc, char * * argv)
 	{
  		if(0==strcmp(argv[i], "-d"))
 			debug_flag = 1;
+		else if(0==strcmp(argv[i], "-D"))
+			foreground_flag = 1;
 #ifdef ENABLE_IPV6
 		else if(0==strcmp(argv[i], "-6"))
 			ipv6 = 1;
@@ -1228,7 +1231,7 @@ int main(int argc, char * * argv)
 #endif
 
 	/* daemonize or in any case get pid ! */
-	if(debug_flag)
+	if(debug_flag || foreground_flag)
 		pid = getpid();
 	else {
 #ifdef USE_DAEMON
