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

  • SEARCH
  • Home
  • 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 8370327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:53:23+00:00 2026-06-09T13:53:23+00:00

When a Pid dies it frees all file handles/ports that are associated with it.

  • 0

When a Pid dies it frees all file handles/ports that are associated with it. If the process is about to die should I bother calling something like gen_tcp:close or ssl:close even if it’s the last thing it does?

  • 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-09T13:53:25+00:00Added an answer on June 9, 2026 at 1:53 pm

    By “should I bother” do you mean, “will I risk a memory leak?”, or “could it result in data loss?”, or “does it affect how the client sees and closes the connection?”

    That being said, it is considered polite to issue the close command, for the client’s sake. The client might see an abrupt break in the connection instead of a close. For example, if it’s a web server, and you do not send the close, then certain browsers will read it as an pipe break (error) and immediately try to reconnect. Closing the connection properly is just polite, and it will help keep your code organized logically (you know exactly how all of your resources get handled).

    I’m not 100% sure how erlang handles garbage collection, but I can say that for most programming languages (and thereby I’m assuming erlang as well), killing the process will take care of all of the memory associated with it, so there should be no memory leak in just letting the process die.

    If, however, there is potential content left in a buffer to be sent to the client, you may want to make your exit procedure such that it flushes the buffer or connection before it closes, otherwise you might risk data loss.

    Edit: as legoscia mentioned, any open file descriptors should be handled gracefully by erlang, but it never hurts (and I would call it “good practice”) to close them yourself before exiting the process.

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

Sidebar

Related Questions

assuming that I know the PID of a process and want to do a
After DJ dies the log files indicate nothing. running: ./script/delayed_job status gives: pid-file for
What is the PID assignment policy in Windows? Repeated runs of a process calling
I noticed that messages sent to the pid of a gen_fsm process are matched
Is there any way to determine the PID of a process that was started
I am running a python process on an Amazon EC2 Ubuntu instance that processes
I have the pid (process identifier) of an arbitrary running process. How can I
A native application I wrote uses /proc/PID/status name variable. However, it appears that the
i want to save the PID of a background process and save it to
I have the pid of a running process in freebsd. How do I obtain

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.