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 6076977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:07+00:00 2026-05-23T10:40:07+00:00

I have a supervisor (called alice) which starts a bunch of_one_for_one workers. Now I’d

  • 0

I have a supervisor (called alice) which starts a bunch of_one_for_one workers. Now I’d like to get some info about all of the works together. For instance, let’s say workers are TCP servers and I’d like to get all port numbers used by workers, or all remote addresses which are connected to those workers. Where should I put this functionality?

Supervisor doesn’t have gen_server functionality and cannot answer calls. So, it seems to me, the most reasonable way is to have another supervisor (called bob) which spawns supervisor alice and another gen_server (charile) which implements calls like {get, ports_used_by_alices_workers} by calling supervisor:which_children(alice) and then asking each alice’s child for it’s port. So, charile is alice’s sibling and answers calls about alice’s children. Is that OK? Or is there a more elegant way of doing this?

  • 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-05-23T10:40:08+00:00Added an answer on May 23, 2026 at 10:40 am

    You don’t need a separate process to collect this information – you can just let whoever wants the port information collect it themselves by getting the list of children with supervisor:which_children/1 and then querying each child. Provide an API function that does this, but let that function run in the caller’s process.

    Alternately, you could go the undocumented (and warranty voiding) route, and poke around in the guts of erlang to get the information you want without talking to the children at all:

    [{Child, 
      %% Query linked port for socket information
      [{Link, prim_inet:sockname(Link),
              prim_inet:peername(Link)}
        || %% get list of linked process and ports for process 'Child'
           Link <- element(2, process_info(Child, links)),
           %% filter down to linked ports.
           is_port(Link)] 
      }
     %% Map over all children of the supervisor 'Sup'.
     || Child <- [Pid || {_,Pid,_,_} = supervisor:which_children(Sup)] 
     ]
    

    You can get an idea of the information available in the source for inet:i/0.

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

Sidebar

Related Questions

I have a supervisor which starts simple_one_for_one children. Each child is in fact a
I have a supervisor which should start simple_one_for_one workers. When I call start_child() for
I have a table called userstbl that has supId (supervisor) and has also userID
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have 2 tables, Student and Supervisor: STUDENT (supervisorid(pk),name,email....) SUPERVISOR (supervisorid(pk),name,email....) Now I need
Let us say I have one supervisor and I need execute some start_child for
I have a supervisor with two worker processes: a TCP client which handles connection
I have been asked by my supervisor to develop a web application using either
I have an 'superior object' of type HierarchyNode which will have childnodes (each child
have written this little class, which generates a UUID every time an object of

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.