{
fprintf(stderr, _("\n%s: could not stop postmaster: exit code was %d\n"),
progname, r);
- exit(2); /* not exit_nicely(), that would be recursive */
+ _exit(2); /* not exit(), that could be recursive */
}
postmaster_running = false;
}
}
-/*
- * Always exit through here, not through plain exit(), to ensure we make
- * an effort to shut down a temp postmaster
- */
-void
-exit_nicely(int code)
-{
- stop_postmaster();
- exit(code);
-}
-
/*
* Check whether string matches pattern
*
names = pgfnames(indir);
if (!names)
/* Error logged in pgfnames */
- exit_nicely(2);
+ exit(2);
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
{
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
progname, srcfile, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
outfile = fopen(destfile, "w");
if (!outfile)
{
fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
progname, destfile, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
while (fgets(line, sizeof(line), infile))
{
{
fprintf(stderr, _("%s: no *.source files found in \"%s\"\n"),
progname, indir);
- exit_nicely(2);
+ exit(2);
}
pgfnames_cleanup(names);
return;
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
progname, buf, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
while (fgets(buf, sizeof(buf), f))
{
fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
buf);
- exit_nicely(2);
+ exit(2);
}
*file_type++ = '\0';
{
fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
buf);
- exit_nicely(2);
+ exit(2);
}
*platform++ = '\0';
expected = strchr(platform, '=');
{
fprintf(stderr, _("incorrectly formatted resultmap entry: %s\n"),
buf);
- exit_nicely(2);
+ exit(2);
}
*expected++ = '\0';
{
/* psql probably already reported the error */
fprintf(stderr, _("command failed: %s\n"), psql_cmd);
- exit_nicely(2);
+ exit(2);
}
}
{
fprintf(stderr, _("%s: could not fork: %s\n"),
progname, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
if (pid == 0)
{
execl(shellprog, shellprog, "-c", cmdline2, (char *) NULL);
fprintf(stderr, _("%s: could not exec \"%s\": %s\n"),
progname, shellprog, strerror(errno));
- exit(1); /* not exit_nicely here... */
+ _exit(1); /* not exit() here... */
}
/* in parent */
return pid;
FreeLibrary(Advapi32Handle);
fprintf(stderr, _("%s: cannot create restricted tokens on this platform\n"),
progname);
- exit_nicely(2);
+ exit(2);
}
/* Open the current token to use as base for the restricted one */
{
fprintf(stderr, _("could not open process token: error code %lu\n"),
GetLastError());
- exit_nicely(2);
+ exit(2);
}
/* Allocate list of SIDs to remove */
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, 0, &dropSids[1].Sid))
{
fprintf(stderr, _("could not allocate SIDs: error code %lu\n"), GetLastError());
- exit_nicely(2);
+ exit(2);
}
b = _CreateRestrictedToken(origToken,
{
fprintf(stderr, _("could not create restricted token: error code %lu\n"),
GetLastError());
- exit_nicely(2);
+ exit(2);
}
cmdline2 = malloc(strlen(cmdline) + 8);
{
fprintf(stderr, _("could not start process for \"%s\": error code %lu\n"),
cmdline2, GetLastError());
- exit_nicely(2);
+ exit(2);
}
free(cmdline2);
{
fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
progname, dir, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
}
if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
{
fprintf(stderr, _("diff command failed with status %d: %s\n"), r, cmd);
- exit_nicely(2);
+ exit(2);
}
#ifdef WIN32
if (WEXITSTATUS(r) == 1 && file_size(filename) <= 0)
{
fprintf(stderr, _("diff command not found: %s\n"), cmd);
- exit_nicely(2);
+ exit(2);
}
#endif
{
fprintf(stderr, _("failed to wait for subprocesses: %s\n"),
strerror(errno));
- exit_nicely(2);
+ exit(2);
}
#else
DWORD exit_status;
{
fprintf(stderr, _("failed to wait for subprocesses: error code %lu\n"),
GetLastError());
- exit_nicely(2);
+ exit(2);
}
p = active_pids[r - WAIT_OBJECT_0];
/* compact the active_pids array */
{
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
progname, schedule, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
while (fgets(scbuf, sizeof(scbuf), scf))
{
fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"),
schedule, line_num, scbuf);
- exit_nicely(2);
+ exit(2);
}
num_tests = 0;
/* can't print scbuf here, it's already been trashed */
fprintf(stderr, _("too many parallel tests in schedule file \"%s\", line %d\n"),
schedule, line_num);
- exit_nicely(2);
+ exit(2);
}
tests[num_tests] = c;
num_tests++;
{
fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"),
schedule, line_num, scbuf);
- exit_nicely(2);
+ exit(2);
}
if (num_tests == 1)
{
fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
progname, logfilename, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
/* create the diffs file as empty */
{
fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
progname, difffilename, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
/* we don't keep the diffs file open continuously */
fclose(difffile);
if (!getcwd(cwdbuf, sizeof(cwdbuf)))
{
fprintf(stderr, _("could not get current working directory: %s\n"), strerror(errno));
- exit_nicely(2);
+ exit(2);
}
}
progname = get_progname(argv[0]);
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_regress"));
+ atexit(stop_postmaster);
+
#ifndef HAVE_UNIX_SOCKETS
/* no unix domain sockets available, so change default */
hostname = "localhost";
{
case 'h':
help();
- exit_nicely(0);
+ exit(0);
case 'V':
puts("pg_regress (PostgreSQL) " PG_VERSION);
- exit_nicely(0);
+ exit(0);
case 1:
/*
/* getopt_long already emitted a complaint */
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
progname);
- exit_nicely(2);
+ exit(2);
}
}
if (!top_builddir)
{
fprintf(stderr, _("--top-builddir must be specified when using --temp-install\n"));
- exit_nicely(2);
+ exit(2);
}
if (directory_exists(temp_install))
if (system(buf))
{
fprintf(stderr, _("\n%s: installation failed\nExamine %s/log/install.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
- exit_nicely(2);
+ exit(2);
}
for (sl = extra_install; sl != NULL; sl = sl->next)
makeprog, top_builddir, sl->str, temp_install, outputdir);
#else
fprintf(stderr, _("\n%s: --extra-install option not supported on this platform\n"), progname);
- exit_nicely(2);
+ exit(2);
#endif
if (system(buf))
{
fprintf(stderr, _("\n%s: installation failed\nExamine %s/log/install.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
- exit_nicely(2);
+ exit(2);
}
}
if (system(buf))
{
fprintf(stderr, _("\n%s: initdb failed\nExamine %s/log/initdb.log for the reason.\nCommand was: %s\n"), progname, outputdir, buf);
- exit_nicely(2);
+ exit(2);
}
/*
if (pg_conf == NULL)
{
fprintf(stderr, _("\n%s: could not open \"%s\" for adding extra config: %s\n"), progname, buf, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
fputs("max_prepared_transactions = 2\n", pg_conf);
if (extra_conf == NULL)
{
fprintf(stderr, _("\n%s: could not open \"%s\" to read extra config: %s\n"), progname, temp_config, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
while (fgets(line_buf, sizeof(line_buf), extra_conf) != NULL)
fputs(line_buf, pg_conf);
if (!port_specified_by_user)
fprintf(stderr, _("%s: could not determine an available port\n"), progname);
fprintf(stderr, _("Specify an unused port using the --port option or shut down any conflicting PostgreSQL servers.\n"));
- exit_nicely(2);
+ exit(2);
}
fprintf(stderr, _("port %d apparently in use, trying %d\n"), port, port + 1);
{
fprintf(stderr, _("\n%s: could not spawn postmaster: %s\n"),
progname, strerror(errno));
- exit_nicely(2);
+ exit(2);
}
/*
#endif
{
fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
- exit_nicely(2);
+ exit(2);
}
pg_usleep(1000000L);
progname, GetLastError());
#endif
- exit_nicely(2);
+ exit(2);
}
postmaster_running = true;
}
if (fail_count != 0)
- exit_nicely(1);
+ exit(1);
return 0;
}