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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:15:35+00:00 2026-05-23T23:15:35+00:00

After watching the Pragmatic Studio screen casts on Erlang, the last video on Supervisors

  • 0

After watching the Pragmatic Studio screen casts on Erlang, the last video on Supervisors mentioned that in order for a supervisor to get a notification about one of its children so it can properly restart it, the child should register with process_flag(trap_exit, true). Perhaps I just misunderstood the author (and chances are VERY high that I did misunderstand), but I thought supervisors automagically know when their children die (probably through spawn_link or something similar in the background). Is this really necessary? When should one use process_flag(trap_exit, true) in a real world case because the documentation explicitly states the following:

http://www.erlang.org/doc/man/erlang.html#process_flag-2

process_flag(trap_exit, Boolean)

When trap_exit is set to true, exit signals arriving to a process are converted to {‘EXIT’, From, Reason} messages, which can be received as ordinary messages. If trap_exit is set to false, the process exits if it receives an exit signal other than normal and the exit signal is propagated to its linked processes. Application processes should normally not trap exits.“

  • 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-23T23:15:36+00:00Added an answer on May 23, 2026 at 11:15 pm

    You have 3 idioms:

    1/ I don’t care if my child process dies:

    spawn(...)
    

    2/ I want to crash if my child process crashes:

    spawn_link(...)
    

    3/ I want to receive a message if my child process terminates (normally or not):

    process_flag(trap_exit, true),
    spawn_link(...)
    

    Please see this example and try different values (inverse with 2 or 0 to provoke an exception, and using trap_exit or not):

    -module(play).
    -compile(export_all).
    
    start() ->
        process_flag(trap_exit, true),
        spawn_link(?MODULE, inverse, [2]),
        loop().
    
    loop() ->
        receive
            Msg -> io:format("~p~n", [Msg])
        end,
        loop().
    
    inverse(N) -> 1/N.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After watching this Google I/O video on GWT performance it is obvious that the
After watching the WWDC video on the accelerate framework, I saw that it had
After watching a YouTube video on the Diffie-Hellman Key Exchange , I wanted to
Introduction After watching this video from LIDNUG, about .NET code protection http://secureteam.net/lidnug_recording/Untitled.swf (especially from
After watching this video , I am wondering if I am using my controllers
After watching the latest hanselminutes on 9 video, I went to our dev environment
After watching this video , I started thinking about how I could implement something
I'm building my first GAE app. After watching a tutorial video on youtube, (
After watching the Knockout.JS video with Steve Sanderson I decided this would be great
After watching Channel 9's video on F# Type Providers, I'm wondering about data schema

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.