Пример #1
0
/*
 * syslogger_forkexec() -
 *
 * Format up the arglist for, then fork and exec, a syslogger process
 */
static pid_t
syslogger_forkexec(void)
{
	char	   *av[10];
	int			ac = 0;
	char		filenobuf[32];

	av[ac++] = "postgres";
	av[ac++] = "--forklog";
	av[ac++] = NULL;			/* filled in by postmaster_forkexec */

	/* static variables (those not passed by write_backend_variables) */
#ifndef WIN32
	if (syslogFile != NULL)
		snprintf(filenobuf, sizeof(filenobuf), "%d",
				 fileno(syslogFile));
	else
		strcpy(filenobuf, "-1");
#else							/* WIN32 */
	if (syslogFile != NULL)
		snprintf(filenobuf, sizeof(filenobuf), "%ld",
				 (long) _get_osfhandle(_fileno(syslogFile)));
	else
		strcpy(filenobuf, "0");
#endif   /* WIN32 */
	av[ac++] = filenobuf;

	av[ac] = NULL;
	Assert(ac < lengthof(av));

	return postmaster_forkexec(ac, av);
}
Пример #2
0
/*
 * autovac_forkexec()
 *
 * Format up the arglist for the autovacuum process, then fork and exec.
 */
static pid_t
autovac_forkexec(void)
{
    char	   *av[10];
    int			ac = 0;

    av[ac++] = "postgres";
    av[ac++] = "--forkautovac";
    av[ac++] = NULL;			/* filled in by postmaster_forkexec */
    av[ac] = NULL;

    Assert(ac < lengthof(av));

    return postmaster_forkexec(ac, av);
}
Пример #3
0
/*
 * forkexec routine for the continuous query launcher process.
 *
 * Format up the arglist, then fork and exec.
 */
static pid_t
cqscheduler_forkexec(void)
{
	char *av[10];
	int ac = 0;

	av[ac++] = "pipeline-server";
	av[ac++] = "--forkcqscheduler";
	av[ac++] = NULL; /* filled in by postmaster_forkexec */
	av[ac] = NULL;

	Assert(ac < lengthof(av));

	return postmaster_forkexec(ac, av);
}
Пример #4
0
/*
 * ServiceForkExec()
 *
 * Format up the arglist for the service process, then fork and exec.
 */
pid_t
ServiceForkExec(ServiceConfig *serviceConfig)
{
	char	   *av[10];
	int			ac = 0;
#define MAX_FORK_PARAMETER_LEN 25
	char		forkParameter[MAX_FORK_PARAMETER_LEN];
	int			len;

	len = sprintf(forkParameter, "--fork%s",serviceConfig->forkTitle);
	Assert(len > 0 && len < MAX_FORK_PARAMETER_LEN);

	av[ac++] = "postgres";
	av[ac++] = forkParameter;
	av[ac++] = NULL;			/* filled in by postmaster_forkexec */
	av[ac] = NULL;

	Assert(ac < lengthof(av));

	return postmaster_forkexec(ac, av);
}
Пример #5
0
/*
 * syslogger_forkexec() -
 *
 * Format up the arglist for, then fork and exec, a syslogger process
 */
static pid_t
syslogger_forkexec(void)
{
	char	   *av[10];
	int			ac = 0,
				bufc = 0,
				i;
	char		numbuf[2][32];

	av[ac++] = "postgres";
	av[ac++] = "-forklog";
	av[ac++] = NULL;			/* filled in by postmaster_forkexec */

	/* static variables (those not passed by write_backend_variables) */
#ifndef WIN32
	if (syslogFile != NULL)
		snprintf(numbuf[bufc++], 32, "%d", fileno(syslogFile));
	else
		strcpy(numbuf[bufc++], "-1");
	snprintf(numbuf[bufc++], 32, "%d", (int) redirection_done);
#else							/* WIN32 */
	if (syslogFile != NULL)
		snprintf(numbuf[bufc++], 32, "%ld",
				 _get_osfhandle(_fileno(syslogFile)));
	else
		strcpy(numbuf[bufc++], "0");
	snprintf(numbuf[bufc++], 32, "%d", (int) redirection_done);
#endif   /* WIN32 */

	/* Add to the arg list */
	Assert(bufc <= lengthof(numbuf));
	for (i = 0; i < bufc; i++)
		av[ac++] = numbuf[i];

	av[ac] = NULL;
	Assert(ac < lengthof(av));

	return postmaster_forkexec(ac, av);
}