本文整理汇总了C++中proc_exit函数的典型用法代码示例。如果您正苦于以下问题:C++ proc_exit函数的具体用法?C++ proc_exit怎么用?C++ proc_exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了proc_exit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finish_sync_worker
finish_sync_worker(void)
{
/*
* Commit any outstanding transaction. This is the usual case, unless
* there was nothing to do for the table.
*/
if (IsTransactionState())
{
CommitTransactionCommand();
pgstat_report_stat(false);
}
/* And flush all writes. */
XLogFlush(GetXLogWriteRecPtr());
StartTransactionCommand();
ereport(LOG,
(errmsg("logical replication table synchronization worker for subscription \"%s\", table \"%s\" has finished",
MySubscription->name,
get_rel_name(MyLogicalRepWorker->relid))));
CommitTransactionCommand();
/* Find the main apply worker and signal it. */
logicalrep_worker_wakeup(MyLogicalRepWorker->subid, InvalidOid);
/* Stop gracefully */
proc_exit(0);
}
示例2: HandleStartupProcInterrupts
/* Handle SIGHUP and SIGTERM signals of startup process */
void
HandleStartupProcInterrupts(void)
{
/*
* Check if we were requested to re-read config file.
*/
if (got_SIGHUP)
{
got_SIGHUP = false;
ProcessConfigFile(PGC_SIGHUP);
}
/*
* Check if we were requested to exit without finishing recovery.
*/
if (shutdown_requested)
proc_exit(1);
/*
* Emergency bailout if postmaster has died. This is to avoid the
* necessity for manual cleanup of all postmaster children.
*/
if (IsUnderPostmaster && !PostmasterIsAlive())
exit(1);
}
示例3: sys_exit_group
long
sys_exit_group(va_list ap)
{
int status = va_arg(ap, int);
proc_exit(status);
while (1); /* We don't return after this */
return 0;
}
示例4: config_log_main
static void
config_log_main(Datum main_arg)
{
config_log_objects *objects;
pqsignal(SIGTERM, config_log_sigterm);
pqsignal(SIGHUP, config_log_sighup);
/* We're now ready to receive signals */
BackgroundWorkerUnblockSignals();
/* Connect to database */
BackgroundWorkerInitializeConnection(config_log_database, NULL);
/* Verify expected objects exist */
objects = initialize_objects();
while (!got_sigterm)
{
int rc;
rc = WaitLatch(&MyProc->procLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
100000L);
ResetLatch(&MyProc->procLatch);
/* emergency bailout if postmaster has died */
if (rc & WL_POSTMASTER_DEATH)
proc_exit(1);
/*
* In case of a SIGHUP, just reload the configuration.
*/
if (got_sighup)
{
got_sighup = false;
ProcessConfigFile(PGC_SIGHUP);
execute_pg_settings_logger(objects);
}
}
proc_exit(0);
}
示例5: StartupProcessMain
/* ----------------------------------
* Startup Process main entry point
* ----------------------------------
*/
void
StartupProcessMain(void)
{
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too.
*/
#ifdef HAVE_SETSID
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
/*
* Properly accept or ignore signals the postmaster might send us.
*/
pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
InitializeTimeouts(); /* establishes SIGALRM handler */
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, StartupProcSigUsr1Handler);
pqsignal(SIGUSR2, StartupProcTriggerHandler);
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
/*
* Register timeouts needed for standby mode
*/
RegisterTimeout(STANDBY_DEADLOCK_TIMEOUT, StandbyDeadLockHandler);
RegisterTimeout(STANDBY_TIMEOUT, StandbyTimeoutHandler);
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
PG_SETMASK(&UnBlockSig);
/*
* Do what we came for.
*/
StartupXLOG();
/*
* Exit normally. Exit code 0 tells postmaster that we completed recovery
* successfully.
*/
proc_exit(0);
}
示例6: proc_entry
/**
* Entry point for all the processes.
*/
void proc_entry(void)
{
/*
* Return from a context switch assumes interrupts are disabled, so
* we need to explicitly re-enable them as soon as possible.
*/
IRQ_ENABLE;
/* Call the actual process's entry point */
proc_run();
proc_exit();
}
示例7: auth_failed
/*
* Tell the user the authentication failed, but not (much about) why.
*
* There is a tradeoff here between security concerns and making life
* unnecessarily difficult for legitimate users. We would not, for example,
* want to report the password we were expecting to receive...
* But it seems useful to report the username and authorization method
* in use, and these are items that must be presumed known to an attacker
* anyway.
* Note that many sorts of failure report additional information in the
* postmaster log, which we hope is only readable by good guys.
*/
static void
auth_failed(Port *port, int status)
{
const char *authmethod = "Unknown auth method:";
/*
* If we failed due to EOF from client, just quit; there's no point in
* trying to send a message to the client, and not much point in
* logging the failure in the postmaster log. (Logging the failure
* might be desirable, were it not for the fact that libpq closes the
* connection unceremoniously if challenged for a password when it
* hasn't got one to send. We'll get a useless log entry for every
* psql connection under password auth, even if it's perfectly
* successful, if we log STATUS_EOF events.)
*/
if (status == STATUS_EOF)
proc_exit(0);
switch (port->auth_method)
{
case uaReject:
authmethod = "Rejected host:";
break;
case uaKrb4:
authmethod = "Kerberos4";
break;
case uaKrb5:
authmethod = "Kerberos5";
break;
case uaTrust:
authmethod = "Trusted";
break;
case uaIdent:
authmethod = "IDENT";
break;
case uaMD5:
case uaCrypt:
case uaPassword:
authmethod = "Password";
break;
#ifdef USE_PAM
case uaPAM:
authmethod = "PAM";
break;
#endif /* USE_PAM */
}
ereport(FATAL,
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
errmsg("%s authentication failed for user \"%s\"",
authmethod, port->user_name)));
/* doesn't return */
}
示例8: ProcessStandbyMessage
/*
* Process a status update message received from standby.
*/
static void
ProcessStandbyMessage(void)
{
char msgtype;
resetStringInfo(&reply_message);
/*
* Read the message contents.
*/
if (pq_getmessage(&reply_message, 0))
{
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("unexpected EOF on standby connection")));
proc_exit(0);
}
/*
* Check message type from the first byte.
*/
msgtype = pq_getmsgbyte(&reply_message);
switch (msgtype)
{
case 'r':
ProcessStandbyReplyMessage();
break;
case 'h':
ProcessStandbyHSFeedbackMessage();
break;
default:
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("unexpected message type \"%c\"", msgtype)));
proc_exit(0);
}
}
示例9: StartupProcShutdownHandler
/* SIGTERM: set flag to abort redo and exit */
static void
StartupProcShutdownHandler(SIGNAL_ARGS)
{
int save_errno = errno;
if (in_restore_command)
proc_exit(1);
else
shutdown_requested = true;
WakeupRecovery();
errno = save_errno;
}
示例10: PreRestoreCommand
void
PreRestoreCommand(void)
{
/*
* Set in_restore_command to tell the signal handler that we should exit
* right away on SIGTERM. We know that we're at a safe point to do that.
* Check if we had already received the signal, so that we don't miss a
* shutdown request received just before this.
*/
in_restore_command = true;
if (shutdown_requested)
proc_exit(1);
}
示例11: hello_main
void
hello_main(Datum main_arg)
{
/* Register functions for SIGTERM/SIGHUP management */
pqsignal(SIGHUP, hello_sighup);
pqsignal(SIGTERM, hello_sigterm);
/* We're now ready to receive signals */
BackgroundWorkerUnblockSignals();
while (true)
{
/* Wait 1s */
WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
1000L,
PG_WAIT_EXTENSION);
ResetLatch(MyLatch);
/* Process signals */
if (got_sighup)
{
/* Process config file */
ProcessConfigFile(PGC_SIGHUP);
got_sighup = false;
ereport(LOG, (errmsg("hello signal: processed SIGHUP")));
}
if (got_sigterm)
{
/* Simply exit */
ereport(LOG, (errmsg("hello signal: processed SIGTERM")));
proc_exit(0);
}
}
/* No problems, so clean exit */
proc_exit(0);
}
示例12: BufferSaverMain
static void
BufferSaverMain(Datum main_arg)
{
WorkerCommon();
/*
* Main loop: do this until the SIGTERM handler tells us to terminate
*/
while (!got_sigterm)
{
int rc;
ResetLatch(&MyProc->procLatch);
/*
* Wait on the process latch, which sleeps as necessary, but is awakened
* if postmaster dies. This way the background process goes away
* immediately in case of an emergency.
*/
rc = WaitLatch(&MyProc->procLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
10 * 1000L);
/* emergency bailout if postmaster has died */
if (rc & WL_POSTMASTER_DEATH)
proc_exit(1);
/*
* In case of a SIGHUP, just reload the configuration.
*/
if (got_sighup)
{
got_sighup = false;
ProcessConfigFile(PGC_SIGHUP);
}
}
/*
* We recieved the SIGTERM; Shutdown is in progress, so save the
* shared-buffer contents.
*/
/* Save the buffers only if the extension is enabled. */
if (guc_enabled)
SaveBuffers();
/*
* The worker exits here. A proc_exit(0) is not necessary, we'll let the
* caller do that.
*/
}
示例13: worker_main
void worker_main(Datum arg)
{
int ret;
StringInfoData buf;
uint32 segment = UInt32GetDatum(arg);
/* Setup signal handlers */
pqsignal(SIGHUP, worker_sighup);
pqsignal(SIGTERM, worker_sigterm);
/* Allow signals */
BackgroundWorkerUnblockSignals();
initialize_worker(segment);
/* Connect to the database */
BackgroundWorkerInitializeConnection(job->datname, job->rolname);
elog(LOG, "%s initialized running job id %d", MyBgworkerEntry->bgw_name, job->job_id);
pgstat_report_appname(MyBgworkerEntry->bgw_name);
/* Initialize the query text */
initStringInfo(&buf);
appendStringInfo(&buf,
"SELECT * FROM %s.%s(%d, NULL)",
job_run_function.schema,
job_run_function.name,
job->job_id);
/* Initialize the SPI subsystem */
SetCurrentStatementStartTimestamp();
StartTransactionCommand();
SPI_connect();
PushActiveSnapshot(GetTransactionSnapshot());
pgstat_report_activity(STATE_RUNNING, buf.data);
SetCurrentStatementStartTimestamp();
/* And run the query */
ret = SPI_execute(buf.data, true, 0);
if (ret < 0)
elog(FATAL, "errors while executing %s", buf.data);
/* Commmit the transaction */
SPI_finish();
PopActiveSnapshot();
CommitTransactionCommand();
pgstat_report_activity(STATE_IDLE, NULL);
proc_exit(0);
}
示例14: CheckClosedConnection
/*
* Check if the remote end has closed the connection.
*/
static void
CheckClosedConnection(void)
{
unsigned char firstchar;
int r;
r = pq_getbyte_if_available(&firstchar);
if (r < 0)
{
/* unexpected error or EOF */
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("unexpected EOF on standby connection")));
proc_exit(0);
}
if (r == 0)
{
/* no data available without blocking */
return;
}
/* Handle the very limited subset of commands expected in this phase */
switch (firstchar)
{
/*
* 'X' means that the standby is closing down the socket.
*/
case 'X':
proc_exit(0);
default:
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("invalid standby closing message type %d",
firstchar)));
}
}
示例15: WalSendServer_ServicePostmasterDied
static void
WalSendServer_ServicePostmasterDied(void)
{
if (!isQDMirroringNotConfigured() &&
!isQDMirroringNotKnownYet() &&
!isQDMirroringDisabled())
{
/*
* Only complain if we were trying to do work.
*/
ereport(LOG,
(errmsg("exiting because postmaster has died")));
proc_exit(1);
}
}