diff options
author | Robert Haas <rhaas@postgresql.org> | 2013-10-18 10:21:25 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2013-10-18 10:23:11 -0400 |
commit | 523beaa11bdf6a9864e8978b467ed586b792c9ca (patch) | |
tree | 69243f9df4616e5d79cee9e48dc9943fa495df16 /doc/src | |
parent | c2316dcda1cd057d7d4a56e3a51e3f8f0527e906 (diff) | |
download | postgresql-523beaa11bdf6a9864e8978b467ed586b792c9ca.tar.gz postgresql-523beaa11bdf6a9864e8978b467ed586b792c9ca.zip |
Provide a reliable mechanism for terminating a background worker.
Although previously-introduced APIs allow the process that registers a
background worker to obtain the worker's PID, there's no way to prevent
a worker that is not currently running from being restarted. This
patch introduces a new API TerminateBackgroundWorker() that prevents
the background worker from being restarted, terminates it if it is
currently running, and causes it to be unregistered if or when it is
not running.
Patch by me. Review by Michael Paquier and KaiGai Kohei.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/bgworker.sgml | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/doc/src/sgml/bgworker.sgml b/doc/src/sgml/bgworker.sgml index 9e6dea98a24..6996d731868 100644 --- a/doc/src/sgml/bgworker.sgml +++ b/doc/src/sgml/bgworker.sgml @@ -184,13 +184,18 @@ typedef struct BackgroundWorker argument to <function>RegisterDynamicBackgroundWorker</function>. If the worker is successfully registered, this pointer will be initialized with an opaque handle that can subsequently be passed to - <function>GetBackgroundWorkerPid(<parameter>BackgroundWorkerHandle *</parameter>, <parameter>pid_t *</parameter>)</function>. - This function can be used to poll the status of the worker: a return - value of <literal>BGWH_NOT_YET_STARTED</> indicates that the worker has not - yet been started by the postmaster; <literal>BGWH_STOPPED</literal> - indicates that it has been started but is no longer running; and - <literal>BGWH_STARTED</literal> indicates that it is currently running. - In this last case, the PID will also be returned via the second argument. + <function>GetBackgroundWorkerPid(<parameter>BackgroundWorkerHandle *</parameter>, <parameter>pid_t *</parameter>)</function> or + <function>TerminateBackgroundWorker(<parameter>BackgroundWorkerHandle *</parameter>)</function>. + <function>GetBackgroundWorker</> can be used to poll the status of the + worker: a return value of <literal>BGWH_NOT_YET_STARTED</> indicates that + the worker has not yet been started by the postmaster; + <literal>BGWH_STOPPED</literal> indicates that it has been started but is + no longer running; and <literal>BGWH_STARTED</literal> indicates that it is + currently running. In this last case, the PID will also be returned via the + second argument. + <function>TerminateBackgroundWorker</> causes the postmaster to send + <literal>SIGTERM</> to the worker if it is running, and to unregister it + as soon as it is not. </para> <para> |