51 lines · 2.0 KB · Text
RawDownload
= exception: obtain data about exceptions and set exception-handling modes     include "exception.m";    exc := load Exception Exception->PATH;     NOTIFYLEADER, PROPAGATE: con iota;     getexc:   fn(pid: int): (int, string, string);    setexcmode:    fn(mode: int): int; Exception provides functions to fetch data  about  exceptionsin  other  processes and change exception-handling modes.  Itencapsulates  exception-related  operations   on   files   inprog(3). When  a process incurs an exception, the system saves detailsbefore processing the  exception,  following  Limbo's  rules.Getexc   returns   a   tuple  (pc, module, description)  thatdescribes the most recent exception raised  in  process  pid.(A  process  id  of -1 is taken to mean the current process.)The tuple contains the pc value, the  module  name,  and  theexception  name.   The  value (0, nil, nil) is returned if noexception has occurred. By default, when a process incurs an exception  that  is  nothandled  —  no  exception clause matches that exception — theprocess is stopped in a `Broken' state for debugging, and theexception does not propagate further.  Setexcmode changes theway that  the  system  handles  exceptions  for  the  currentprocess  and  those  it later spawns.  A mode of NOTIFYLEADERmakes the invoking process the leader of the current  processgroup  for exception handling.  Subsequently, an exception inany process in the  current  process  group  will  atomicallydestroy all processes in the group except the leader, and theexception will be raised in the  leader.   (This  works  evenwhen  the  leader  itself  incurs  the exception.)  A mode ofPROPAGATE instead causes an exception in any process  in  thegroup  to  be  raised in all processes in the group, allowingthem all to initiate local error recovery  (ie,  within  eachprocess). == source/appl/lib/exception.b == diagnosticsBoth  functions  return  -1 on error and set the system errorstring. == see ALSOprog(3)