diff --git a/main/app.c b/main/app.c
index a026f2b8bf7ad0b89b95e79839ba9537e331e161..0d6d9666649888703e4263d18182148c261a0633 100644
--- a/main/app.c
+++ b/main/app.c
@@ -39,6 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <regex.h>
+#include <fcntl.h>
 
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
@@ -1146,8 +1147,14 @@ static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
 	pl->path = strdup(path);
 
 	time(&start);
-	while (((res = flock(pl->fd, LOCK_EX | LOCK_NB)) < 0) &&
-			(errno == EWOULDBLOCK) && (time(NULL) - start < 5))
+	while ((
+		#ifdef SOLARIS
+		(res = fcntl(pl->fd, F_SETLK, fcntl(pl->fd,F_GETFL)|O_NONBLOCK)) < 0) &&
+		#else
+		(res = flock(pl->fd, LOCK_EX | LOCK_NB)) < 0) &&
+		#endif
+			(errno == EWOULDBLOCK) && 
+			(time(NULL) - start < 5))
 		usleep(1000);
 	if (res) {
 		ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n",
diff --git a/main/asterisk.c b/main/asterisk.c
index 7a4acf628ee37f0b49b9694047ba398395eaaab5..ce6cedf66eddceb97e30cbc84fd6a731ebf800af 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -95,6 +95,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <netdb.h>
 #if defined(SOLARIS)
 int daemon(int, int);  /* defined in libresolv of all places */
+#include <sys/loadavg.h>
 #endif
 #endif
 
diff --git a/main/pbx.c b/main/pbx.c
index 666f334588f6923a84d11efc892f6ed89b1066f0..c879c58345f24c86955b7779b6ed124bf5b24b8d 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -40,6 +40,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #if defined(HAVE_SYSINFO)
 #include <sys/sysinfo.h>
 #endif
+#if defined(SOLARIS)
+#include <sys/loadavg.h>
+#endif
 
 #include "asterisk/lock.h"
 #include "asterisk/cli.h"