diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index eaf3f61ecf43fcede4f27ad2b4cf99adfe2e64e5..67ccdce764454244e338ce1314a1cd7a81a78747 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -403,7 +403,6 @@ static void processCancelRequest(Port *port, void *pkt);
 static int	initMasks(fd_set *rmask);
 static void report_fork_failure_to_client(Port *port, int errnum);
 static CAC_state canAcceptConnections(void);
-static long PostmasterRandom(void);
 static void RandomSalt(char *salt, int len);
 static void signal_child(pid_t pid, int signal);
 static bool SignalSomeChildren(int signal, int targets);
@@ -5101,7 +5100,7 @@ RandomSalt(char *salt, int len)
 /*
  * PostmasterRandom
  */
-static long
+long
 PostmasterRandom(void)
 {
 	/*
diff --git a/src/backend/storage/ipc/dsm.c b/src/backend/storage/ipc/dsm.c
index d8066647a07598b63188635d167a8e6ab8ba96f5..edafe4a3b9f3e0d69a02b83e1afd29a589546bf3 100644
--- a/src/backend/storage/ipc/dsm.c
+++ b/src/backend/storage/ipc/dsm.c
@@ -36,6 +36,7 @@
 
 #include "lib/ilist.h"
 #include "miscadmin.h"
+#include "postmaster/postmaster.h"
 #include "storage/dsm.h"
 #include "storage/ipc.h"
 #include "storage/lwlock.h"
@@ -181,7 +182,7 @@ dsm_postmaster_startup(PGShmemHeader *shim)
 	{
 		Assert(dsm_control_address == NULL);
 		Assert(dsm_control_mapped_size == 0);
-		dsm_control_handle = random();
+		dsm_control_handle = (dsm_handle) PostmasterRandom();
 		if (dsm_control_handle == 0)
 			continue;
 		if (dsm_impl_op(DSM_OP_CREATE, dsm_control_handle, segsize,
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index b2d7776f2a8c74a6dcc0ff84a95c57928f25fcdb..ef06d5d04c45ac573e907f75a362517d0a492575 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -48,6 +48,7 @@ extern const char *progname;
 
 extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
 extern void ClosePostmasterPorts(bool am_syslogger);
+extern long PostmasterRandom(void);
 
 extern int	MaxLivePostmasterChildren(void);