Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9008643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:59:24+00:00 2026-06-16T01:59:24+00:00

A postgres client is running a possibly long-running query. The client receives a SIGTERM.

  • 0

A postgres client is running a possibly long-running query. The client receives a SIGTERM. Ideally, I’d like the client to trap the SIGTERM, clean up its query by sending a pg_cancel_backend(pid) and then quit.

This would seem to be a common concern with a client-server database architecture, but I can’t find any solutions. Instead, the query will continue until completion, consuming unnecessary resources.

How can the client determine with certainty the PID of its backend query? (I don’t mean interactively view the backend queries and choosing the one that appears to match the query that was issued.) For example, are PIDs associated with persistent database connections?

How does this work when using psql when ctrl-C is pressed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:59:26+00:00Added an answer on June 16, 2026 at 1:59 am

    You can use pg_backend_pid() to get PID for current connection.

    Details here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I enjoy running Postgres client psql under psql.el while interacting with a .sql file
Need to build a Top 10 query that works with SQLite and Postgres. Client
My Postgres query calculates statistical aggregate from a bunch of sensor readings: SELECT to_char(ipstimestamp,
This query: client.query({ text: SELECT * FROM users WHERE provider = ? AND remote_id
I am creating a postgres multi-tenant environment. So client A has schema_1, B has
In Postgres you can switch on query logging, resulting in a file containing all
I'm trying to connect Tryton to a postgres database. In the Tryton client profile,
I would like to backup my production database before and after running a database
We are running Postgres 9.1.3 and we have recently started to run into major
js and Postgres (using this module) and I would like to view the SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.