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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:12:55+00:00 2026-06-13T14:12:55+00:00

when i read an artical from learnyousomeerlang.com,I got a question. http://learnyousomeerlang.com/errors-and-processes It says that:

  • 0

when i read an artical from learnyousomeerlang.com,I got a question.
http://learnyousomeerlang.com/errors-and-processes

It says that:

Exception source: exit(self(), kill)

Untrapped Result: ** exception exit: killed

Trapped Result: ** exception exit: killed

Oops, look at that. It seems like this one is actually impossible to trap. Let’s check something.

but it does not comply with what I test with the code blow:

  -module(trapexit).
  -compile(export_all).
  self_kill_exit()->
  process_flag(trap_exit,true),
  Pid=spawn_link(fun()->timer:sleep(3000),exit(self(),kill)  end),
  receive
    {_A,Pid,_B}->io:format("subinmain:~p output:~p~n",[Pid,{_A,Pid,_B}])
  end.

oupput is:
**4> trapexit:self_kill_exit().

subinmain:<0.36.0> output:{‘EXIT’,<0.36.0>,killed}**

and does not comply with Trapped Result: ** exception exit: killed said before . which is right???

  • 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-13T14:12:56+00:00Added an answer on June 13, 2026 at 2:12 pm

    The call to self in the body of the function passed as an argument to spawn_link doesn’t return the process calling spawn_link. It’s being evaluated in the newly spawned process and as a result it will return its pid. Make a following change.

    -module(trapexit).
    -compile(export_all).
    self_kill_exit()->
      process_flag(trap_exit,true),
      Self=self(),
      Pid=spawn_link(fun()->timer:sleep(3000),exit(Self,kill)  end),
      receive
        {_A,Pid,_B}->io:format("subinmain:~p output:~p~n",[Pid,{_A,Pid,_B}])
      end.
    

    Now it should work as expected.

    10> c(trapexit).            
    {ok,trapexit}
    11> trapexit:self_kill_exit().
    ** exception exit: killed
    

    The book is right. Trapping exit(self(), kill) is not possible.

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

Sidebar

Related Questions

Read Carefully The question here is not that does PHP parser processes comments or
having read the docs, https://docs.djangoproject.com/en/dev/topics/signals/ i have created this in my signals.py file: from
Read about Server push here . I want to push data to client from
Read about the issue in this stackoverflow question . Still have the same issue
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
I read a text file to get some info from it and later on
Read this question today about safe and unsafe code I then read about it
Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php .
Read my question thoroughly before responding, I know there’s a site called wonderfl.net I‘ve
I read topic from google and I understand this: Windows loader loads the exe

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.