PgChildProcess
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Runs a program from a backend or background worker and waits for it, as pglogical runs pg_dump and
pg_restore to copy a schema.
public static class PgChildProcess
.NET's System.Diagnostics.Process installs its own SIGCHLD handling, which is not safe inside a
PostgreSQL process. This starts the program with posix_spawn on Unix and CreateProcessW on Windows,
and waits on the backend's latch, so query cancellation, statement timeouts and termination still work: they stop
the program before PostgreSQL raises the interrupt.
The program inherits the server's environment, working directory and standard streams, so its output goes to the
server log; pass options such as --file to write results to a file. Arguments are passed exactly, including
spaces, quotes and non-ASCII text. On Windows, a program with a narrow main, which includes PostgreSQL's own
programs, receives them converted to the system's ANSI code page, so non-ASCII text arrives only when that code page
contains it.
Inheritance: object
Methods
Section titled “Methods”Run(string, params ReadOnlySpan<string>)
Section titled “Run(string, params ReadOnlySpan<string>)”Runs a program and waits for it to exit.
public static int Run(string path, params ReadOnlySpan<string> arguments)Parameters:
path — string
The program’s full path, such as pg_dump in the server’s bin directory.
arguments — ReadOnlySpan<string>
The arguments, after the program name.
Returns: int
The exit code, or on Unix 128 plus the signal number when a signal ended the program.
Exceptions:
- PgException: The program could not be started, or the wait was interrupted.