@@ -121,13 +121,22 @@ main(int argc, char **argv)
121121 * hard-coded LOG_INFO as our log level. For now we won't see the log_debug
122122 * output, but as a developer you could always change the LOG_INFO to
123123 * LOG_DEBUG above and then see the message.
124+ *
125+ * When running pg_autoctl using valgrind we also want the subprocesses to
126+ * be run with valgrind. However, valgrind modifies the argv variables to
127+ * be the pg_autoctl binary, instead of the valgrind binary. So to make
128+ * sure subprocesses are spawned using valgrind, we allow overriding To
129+ * this program path detection using the PG_AUTOCTL_DEBUG_BIN_PATH
130+ * environment variable.
124131 */
125132 strlcpy (pg_autoctl_argv0 , argv [0 ], MAXPGPATH );
126-
127- if (!set_program_absolute_path (pg_autoctl_program , MAXPGPATH ))
133+ if (!get_env_copy ("PG_AUTOCTL_DEBUG_BIN_PATH" , pg_autoctl_program , MAXPGPATH ))
128134 {
129- /* errors have already been logged */
130- exit (EXIT_CODE_INTERNAL_ERROR );
135+ if (!set_program_absolute_path (pg_autoctl_program , MAXPGPATH ))
136+ {
137+ /* errors have already been logged */
138+ exit (EXIT_CODE_INTERNAL_ERROR );
139+ }
131140 }
132141
133142 if (!commandline_run (& command , argc , argv ))
0 commit comments