diff --git a/runopts.h b/runopts.h
index 5107a9dff732a05e5156ea7577924708ef441f55..1e102e67070db5addbe3c5bc44e8fcab56fd9d36 100644
--- a/runopts.h
+++ b/runopts.h
@@ -83,6 +83,7 @@ typedef struct svr_runopts {
 
 	sign_key *hostkey;
 	buffer * banner;
+	char * pidfile;
 
 } svr_runopts;
 
diff --git a/svr-main.c b/svr-main.c
index e00de6b2bdb852ca74b8da39b6c7e826c2355818..a14c6e64f6fba07010ebf38da0042f89b5b62e55 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -146,7 +146,7 @@ void main_noinetd() {
 	}
 
 	/* create a PID file so that we can be killed easily */
-	pidfile = fopen(DROPBEAR_PIDFILE, "w");
+	pidfile = fopen(svr_opts.pidfile, "w");
 	if (pidfile) {
 		fprintf(pidfile, "%d\n", getpid());
 		fclose(pidfile);
@@ -189,7 +189,7 @@ void main_noinetd() {
 		val = select(maxsock+1, &fds, NULL, NULL, &seltimeout);
 
 		if (exitflag) {
-			unlink(DROPBEAR_PIDFILE);
+			unlink(svr_opts.pidfile);
 			dropbear_exit("Terminated by signal");
 		}
 		
diff --git a/svr-runopts.c b/svr-runopts.c
index 8d8b8df210f2ede165c18f0e07d68d05cc2b55ea..784e0ca0e6a5e51f953ad7b0646afbe3bc0402e3 100644
--- a/svr-runopts.c
+++ b/svr-runopts.c
@@ -72,6 +72,8 @@ static void printhelp(const char * progname) {
 #endif
 					"-p port		Listen on specified tcp port, up to %d can be specified\n"
 					"		(default %s if none specified)\n"
+					"-P PidFile	Create pid file PidFile\n"
+					"		(default %s)\n"
 #ifdef INETD_MODE
 					"-i		Start for inetd\n"
 #endif
@@ -85,7 +87,7 @@ static void printhelp(const char * progname) {
 #ifdef DROPBEAR_RSA
 					RSA_PRIV_FILENAME,
 #endif
-					DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT);
+					DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE);
 }
 
 void svr_getopts(int argc, char ** argv) {
@@ -105,6 +107,7 @@ void svr_getopts(int argc, char ** argv) {
 	svr_opts.inetdmode = 0;
 	svr_opts.portcount = 0;
 	svr_opts.hostkey = NULL;
+	svr_opts.pidfile = DROPBEAR_PIDFILE;
 #ifdef ENABLE_SVR_LOCALTCPFWD
 	svr_opts.nolocaltcp = 0;
 #endif
@@ -185,6 +188,9 @@ void svr_getopts(int argc, char ** argv) {
 						svr_opts.portcount++;
 					}
 					break;
+				case 'P':
+					next = &svr_opts.pidfile;
+					break;
 #ifdef DO_MOTD
 				/* motd is displayed by default, -m turns it off */
 				case 'm':