When the on-exit callback gets called because of a failure to acquire
shared memory. The cleanup function can produce a segfault while accessing
process_info, that lives in shared memory.
Although we can also fix this by bailing out from the exit callback when
process_info is NULL but installing the function after successful initialization
of shared memory is a better approach as the rest of the system always assumes
the process_info can never be NULL, and also, there is nothing to
clean up before child processes are spawned.
*/
read_status_file(discard_status);
- /*
- * install the call back for preparation of system exit
- */
- on_system_exit(system_will_go_down, (Datum) NULL);
-
/* set unix domain socket path for connections to pgpool */
for (i = 0; i < pool_config->num_unix_socket_directories; i++)
{
initialize_shared_mem_objects(clear_memcache_oidmaps);
+ /*
+ * install the callback for preparation of system exit
+ */
+ on_system_exit(system_will_go_down, (Datum) NULL);
+
/* setup signal handlers */
pool_signal(SIGCHLD, reap_handler);
pool_signal(SIGUSR1, sigusr1_handler);