Skip to content

Feature Request: Ensure embedded Postgres child process is reliably terminated on parent process exit (especially on Windows) #160

@michael-podlejska-snkeos

Description

I’m using embedded-postgres for integration testing on Windows. I’ve noticed that if my test process is killed or crashes, the spawned postgres.exe process is not always terminated, leading to orphaned Postgres processes that must be cleaned up manually.

Steps to reproduce:

Start embedded Postgres using embeddedpostgres.NewDatabase().Start().
Kill the parent Go process (e.g., via Task Manager).
Observe that postgres.exe processes remain running.

Impact:

Orphaned Postgres processes accumulate, consuming system resources and potentially causing port conflicts in subsequent test runs.
Manual cleanup is required, which is error-prone and inconvenient.

Request:
Could you add support for reliably terminating the embedded Postgres process when the parent Go process exits, even if the exit is unclean?
On Windows, this could be achieved by launching postgres.exe in a Job Object, which ensures all child processes are killed when the parent dies.
On Unix-like systems, a similar effect can be achieved with process groups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions