*** a/src/backend/postmaster/autovacuum.c
--- b/src/backend/postmaster/autovacuum.c
***************
*** 362,367 **** StartAutoVacLauncher(void)
--- 362,370 ----
  #ifndef EXEC_BACKEND
  		case 0:
  			/* in postmaster child ... */
+ 
+ 			oom_adjust();
+ 
  			/* Close the postmaster's sockets */
  			ClosePostmasterPorts(false);
  
*** a/src/backend/postmaster/fork_process.c
--- b/src/backend/postmaster/fork_process.c
***************
*** 65,68 **** fork_process(void)
--- 65,84 ----
  	return result;
  }
  
+ void
+ oom_adjust(void)
+ {
+ 	/* adjust oom */
+ 	FILE *oom = fopen("/proc/self/oom_adj", "w");
+ 
+ 	/*
+ 	 * ignore errors we dont really care
+ 	 */
+ 	if (oom)
+ 	{
+ 		fprintf(oom, "0\n");
+ 		fclose(oom);
+ 	}
+ }
+ 
  #endif   /* ! WIN32 */
*** a/src/backend/postmaster/pgarch.c
--- b/src/backend/postmaster/pgarch.c
***************
*** 161,166 **** pgarch_start(void)
--- 161,169 ----
  #ifndef EXEC_BACKEND
  		case 0:
  			/* in postmaster child ... */
+ 
+ 			oom_adjust();
+ 
  			/* Close the postmaster's sockets */
  			ClosePostmasterPorts(false);
  
*** a/src/backend/postmaster/pgstat.c
--- b/src/backend/postmaster/pgstat.c
***************
*** 622,627 **** pgstat_start(void)
--- 622,630 ----
  #ifndef EXEC_BACKEND
  		case 0:
  			/* in postmaster child ... */
+ 
+ 			oom_adjust();
+ 
  			/* Close the postmaster's sockets */
  			ClosePostmasterPorts(false);
  
*** a/src/backend/postmaster/postmaster.c
--- b/src/backend/postmaster/postmaster.c
***************
*** 3056,3061 **** BackendStartup(Port *port)
--- 3056,3063 ----
  	{
  		free(bn);
  
+ 		oom_adjust();
+ 
  		/*
  		 * Let's clean up ourselves as the postmaster child, and close the
  		 * postmaster's listen sockets.  (In EXEC_BACKEND case this is all
*** a/src/backend/postmaster/syslogger.c
--- b/src/backend/postmaster/syslogger.c
***************
*** 530,535 **** SysLogger_Start(void)
--- 530,538 ----
  #ifndef EXEC_BACKEND
  		case 0:
  			/* in postmaster child ... */
+ 
+ 			oom_adjust();
+ 
  			/* Close the postmaster's sockets */
  			ClosePostmasterPorts(true);
  
*** a/src/include/postmaster/fork_process.h
--- b/src/include/postmaster/fork_process.h
***************
*** 13,17 ****
--- 13,18 ----
  #define FORK_PROCESS_H
  
  extern pid_t fork_process(void);
+ extern void oom_adjust(void);
  
  #endif   /* FORK_PROCESS_H */
