aboutsummaryrefslogblamecommitdiffstats
path: root/lib/kernel/doc/src/kernel_app.xml
blob: 9fccb4c7acd55dd1ac2b4c0963cea7876d7d0461 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                       




                                     
                                        


                                                        


                                                                      
 






                                                                              
 








                         
                                                  
               
                                                               

                                                            
                                                                     
                                                             
                                                      
                                                  
                          







                                                                                            





                                                              
                                                    
                                                                          


            





















































                                                                                                                            
                                
                                                                        

                                                                       


                                                        



                                                                             
                                                                       
                                                                      

                                                         



                                                                  


                                               

                                                                         





                                                                      
                                        
                                                                                       


                                                 
                                                               
                                                           
                                                                               


                                                
                                                                        
                                            
                                                                                  
                                
                                                                      
                                                                    
                                    
                                                                                  










                                                                      
                                       
                                                                                           





                                            

                                                                          
                                            


                                                                          



                                                                    
                                                   






                                               


                                                         
                                               

                                                                  


                                                                        
                                                                


                                                         
 
                                                                      
                                                                  

                                                                 

                                                           

                                                                            
 





                                                                         
                      

                                                                


                                                                          
            

                                                    
                                            
                                     

                                                                          
                              



                                                                                                        




                                                                   
                                                                  



                                                                  
                                                                                          


                                                               



                                                                                  
             
                                                                                             
            
                                                                     

                                                  

                                                        
                                                       
                                                                             
                                                         
                                                                                       


                                                         
                                                        
                                                                               
                                         
                                                                                         
             

                                                     
                     





                                                                       


                                                                             
                                     




                                                                        
                                                                
                                                                       



                                                                                         






                                                                         




                                                                           


                                                                       
                                                                                   


                                     
                                                                 
                                                     
                                                                                     
                                              
                                                                    
             

                                                               
                                                                 
                                                                      

                                                               


                                                                  

                                                         
                                                                  
                                                                   
                                                                      
                                                                      
                        


                                                        
                                                                 






                                                                    

                                                                 
                                                                 
                                                              




                                                               



                                                                     




                                                                        



                                                                                      


                                                      
                                                                 
                                                               


                                                                                           
                                                             


                                                                          



                                                                



                                                                                    


                                                
                                        
                                            



                                                                       



                                                             
                                                                                     


                                                                          
             






















                                                                     







                                                                   
                                                                




                                                                       





















                                                                              




                           


















                                                                            

            
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE appref SYSTEM "appref.dtd">

<appref>
  <header>
    <copyright>
      <year>1996</year><year>2017</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.

    </legalnotice>

    <title>kernel</title>
    <prepared></prepared>
    <docno></docno>
    <date></date>
    <rev></rev>
  </header>
  <app>kernel</app>
  <appsummary>The Kernel application.</appsummary>
  <description>
    <p>The Kernel application has all the code necessary to run
      the Erlang runtime system: file servers, code servers,
      and so on.</p>
    <p>The Kernel application is the first application started. It is
      mandatory in the sense that the minimal system based on
      Erlang/OTP consists of Kernel and STDLIB. Kernel
      contains the following functional areas:</p>
    <list type="bulleted">
      <item>Start, stop, supervision, configuration, and distribution of applications</item>
      <item>Code loading</item>
      <item>Logging</item>
      <item>Error logging</item>
      <item>Global name service</item>
      <item>Supervision of Erlang/OTP</item>
      <item>Communication with sockets</item>
      <item>Operating system interface</item>
    </list>
  </description>

  <section>
    <title>Error Logger Event Handlers</title>
    <p>Two standard error logger event handlers are defined in
      the Kernel application. These are described in
      <seealso marker="error_logger"><c>error_logger(3)</c></seealso>.</p>
  </section>

  <section>
      <title>OS Signal Event Handler</title>
      <p>Asynchronous OS signals may be subscribed to via the Kernel applications event manager
          (see <seealso marker="doc/design_principles:des_princ">OTP Design Principles</seealso> and
          <seealso marker="stdlib:gen_event"><c>gen_event(3)</c></seealso>) registered as <c>erl_signal_server</c>.
          A default signal handler is installed which handles the following signals:</p>
          <taglist>
              <tag><c>sigusr1</c></tag>
              <item><p>The default handler will halt Erlang and produce a crashdump
                      with slogan "Received SIGUSR1".
                      This is equivalent to calling <c>erlang:halt("Received SIGUSR1")</c>.
              </p></item>

              <tag><c>sigquit</c></tag>
              <item><p>The default handler will halt Erlang immediately.
                      This is equivalent to calling <c>erlang:halt()</c>.
              </p></item>

              <tag><c>sigterm</c></tag>
              <item><p>The default handler will terminate Erlang normally.
                      This is equivalent to calling <c>init:stop()</c>.
              </p></item>
          </taglist>

          <section>
              <title>Events</title>
              <p>Any event handler added to <c>erl_signal_server</c> must handle the following events.</p>
              <taglist>
                  <tag><c>sighup</c></tag>
                  <item><p>Hangup detected on controlling terminal or death of controlling process</p></item>
                  <tag><c>sigquit</c></tag>
                  <item><p>Quit from keyboard</p></item>
                  <tag><c>sigabrt</c></tag>
                  <item><p>Abort signal from abort</p></item>
                  <tag><c>sigalrm</c></tag>
                  <item><p>Timer signal from alarm</p></item>
                  <tag><c>sigterm</c></tag>
                  <item><p>Termination signal</p></item>
                  <tag><c>sigusr1</c></tag>
                  <item><p>User-defined signal 1</p></item>
                  <tag><c>sigusr2</c></tag>
                  <item><p>User-defined signal 2</p></item>
                  <tag><c>sigchld</c></tag>
                  <item><p>Child process stopped or terminated</p></item>
                  <tag><c>sigstop</c></tag>
                  <item><p>Stop process</p></item>
                  <tag><c>sigtstp</c></tag>
                  <item><p>Stop typed at terminal</p></item>
              </taglist>

              <p>Setting OS signals are described in <seealso marker="os#set_signal/2"><c>os:set_signal/2</c></seealso>.</p>
          </section>
  </section>

  <section>
    <title>Configuration</title>
    <p>The following configuration parameters are defined for the Kernel
      application. For more information about configuration parameters,
    see file <seealso marker="app"><c>app(4)</c></seealso>.</p>
    <taglist>
      <tag><c>browser_cmd = string() | {M,F,A}</c></tag>
      <item>
        <p>When pressing the <em>Help</em> button in a tool such as Debugger,
          the help text (an HTML file <c>File</c>) is by default
          displayed in a Netscape browser, which is required to be
          operational. This parameter can be used to change the command for
          how to display the help text if another browser than Netscape
          is preferred, or if another platform than Unix or Windows is
          used.</p>
        <p>If set to a string <c>Command</c>, the command
          <c>"Command File"</c> is evaluated using
	<seealso marker="os#cmd/1"><c>os:cmd/1</c></seealso>.</p>
        <p>If set to a module-function-args tuple, <c>{M,F,A}</c>,
          the call <c>apply(M,F,[File|A])</c> is evaluated.</p>
      </item>
      <tag><c>distributed = [Distrib]</c></tag>
      <item>
        <p>Specifies which applications that are distributed and on which
          nodes they are allowed to execute. In this parameter:</p>
        <list type="bulleted">
          <item><c>Distrib = {App,Nodes} | {App,Time,Nodes}</c></item>
          <item><c>App = atom()</c></item>
          <item><c>Time = integer()>0</c></item>
          <item><c>Nodes = [node() | {node(),...,node()}]</c></item>
        </list>
        <p>The parameter is described in
	  <seealso marker="application#load/2"><c>application:load/2</c></seealso>.</p>
      </item>
      <tag><c>dist_auto_connect = Value</c></tag>
      <item>
        <p>Specifies when nodes are automatically connected. If
          this parameter is not specified, a node is always
          automatically connected, for example, when a message is to be sent to
          that node. <c>Value</c> is one of:</p>
        <taglist>
          <tag><c>never</c></tag>
          <item><p>Connections are never automatically established, they
           must be explicitly connected. See
	   <seealso marker="net_kernel"><c>net_kernel(3)</c></seealso>.</p></item>
          <tag><c>once</c></tag>
          <item><p>Connections are established automatically, but only
           once per node. If a node goes down, it must thereafter be
           explicitly connected. See
	   <seealso marker="net_kernel"><c>net_kernel(3)</c></seealso>.</p></item>
        </taglist>
      </item>
      <tag><c>permissions = [Perm]</c></tag>
      <item>
        <p>Specifies the default permission for applications when they
          are started. In this parameter:</p>
        <list type="bulleted">
          <item><c>Perm = {ApplName,Bool}</c></item>
          <item><c>ApplName = atom()</c></item>
          <item><c>Bool = boolean()</c></item>
        </list>
        <p>Permissions are described in
	  <seealso marker="application#permit/2"><c>application:permit/2</c></seealso>.</p>
      </item>
      <tag><c>error_logger = Value</c></tag>
      <item>
        <p><c>Value</c> is one of:</p>
        <taglist>
          <tag><c>tty</c></tag>
          <item><p>Installs the standard event handler, which prints error
           reports to <c>stdio</c>. This is the default option.</p></item>
          <tag><c>{file, FileName}</c></tag>
          <item><p>Installs the standard event handler, which prints error
           reports to file <c>FileName</c>, where <c>FileName</c>
           is a string.</p></item>
          <tag><c>false</c></tag>
          <item>
            <p>No standard event handler is installed, but
              the initial, primitive event handler is kept, printing
              raw event messages to <c>tty</c>.</p>
          </item>
          <tag><c>silent</c></tag>
          <item>
            <p>Error logging is turned off.</p>
          </item>
        </taglist>
      </item>
      <tag><c>error_logger_format_depth = Depth</c></tag>
      <item>
        <marker id="error_logger_format_depth"></marker>
	<p>Can be used to limit the size of the
	formatted output from the error logger event handlers.</p>

	<note><p>This configuration parameter was introduced in OTP 18.1
	and is experimental. Based on user feedback, it
	can be changed or improved in future releases, for example,
	to gain better control over how to limit the size of the
	formatted output. We have no plans to remove this
	new feature entirely, unless it turns out to be
	useless.</p></note>

        <p><c>Depth</c> is a positive integer representing the maximum
        depth to which terms are printed by the error logger event
        handlers included in OTP. This
        configuration parameter is used by the two event handlers
        defined by the Kernel application and the two event
        handlers in the SASL application.
	(If you have implemented your own error handlers, this configuration
	parameter has no effect on them.)</p>

	<p><c>Depth</c> is used as follows: Format strings
	passed to the event handlers are rewritten.
	The format controls <c>~p</c> and <c>~w</c> are replaced with
	<c>~P</c> and <c>~W</c>, respectively, and <c>Depth</c> is
	used as the depth parameter. For details, see
	<seealso marker="stdlib:io#format/2"><c>io:format/2</c></seealso>
	in STDLIB.</p>

	<note><p>A reasonable starting value for <c>Depth</c> is
	<c>30</c>. We recommend to test crashing various processes in your
	application, examine the logs from the crashes, and then
	increase or decrease the value.</p></note>
     </item>
      <tag><c>global_groups = [GroupTuple]</c></tag>
      <item>
        <marker id="global_groups"></marker>
        <p>Defines global groups, see
	  <seealso marker="global_group"><c>global_group(3)</c></seealso>.
	In this parameter:</p>
        <list type="bulleted">
          <item><p><c>GroupTuple = {GroupName, [Node]} | {GroupName, PublishType, [Node]}</c></p></item>
          <item><p><c>GroupName = atom()</c></p></item>
          <item><p><c>PublishType = normal | hidden</c></p></item>
          <item><p><c>Node = node()</c></p></item>
        </list>
      </item>
      <tag><c>inet_default_connect_options = [{Opt, Val}]</c></tag>
      <item>
        <p>Specifies default options for <c>connect</c> sockets,
          see <seealso marker="inet"><c>inet(3)</c></seealso>.</p>
      </item>
      <tag><c>inet_default_listen_options = [{Opt, Val}]</c></tag>
      <item>
        <p>Specifies default options for <c>listen</c> (and
          <c>accept</c>) sockets, see <seealso marker="inet"><c>inet(3)</c></seealso>.</p>
      </item>
      <tag><c>{inet_dist_use_interface, ip_address()}</c></tag>
      <item>
        <p>If the host of an Erlang node has many network interfaces,
          this parameter specifies which one to listen on. For the type definition
	  of <c>ip_address()</c>,
	  see <seealso marker="inet"><c>inet(3)</c></seealso>.</p>
      </item>
      <tag><c>{inet_dist_listen_min, First}</c> and <c>{inet_dist_listen_max, Last}</c></tag>
      <item>
        <p>Defines the <c>First..Last</c> port range for the listener
          socket of a distributed Erlang node.</p>
      </item>
      <tag><c>{inet_dist_listen_options, Opts}</c></tag>
      <item>
	<marker id="inet_dist_listen_options"></marker>
        <p>Defines a list of extra socket options to be used when opening the
	  listening socket for a distributed Erlang node.
	  See <seealso marker="gen_tcp#listen/2"><c>gen_tcp:listen/2</c></seealso>.</p>
      </item>
      <tag><c>{inet_dist_connect_options, Opts}</c></tag>
      <item>
	<marker id="inet_dist_connect_options"></marker>
        <p>Defines a list of extra socket options to be used when connecting to
	  other distributed Erlang nodes.
	  See <seealso marker="gen_tcp#connect/4"><c>gen_tcp:connect/4</c></seealso>.</p>
      </item>
      <tag><c>inet_parse_error_log = silent</c></tag>
      <item>
        <p>If set, no
          <c>error_logger</c> messages are generated when erroneous
          lines are found and skipped in the various Inet configuration
          files.</p>
      </item>
      <tag><c>inetrc = Filename</c></tag>
      <item>
        <p>The name (string) of an Inet user configuration file. For details,
	see section
	<seealso marker="erts:inet_cfg"><c>Inet Configuration</c></seealso>
	in the ERTS User's Guide.</p>
      </item>
      <tag><c>net_setuptime = SetupTime</c></tag>
      <item>
        <marker id="net_setuptime"></marker>
        <p><c>SetupTime</c> must be a positive integer or floating point
          number, and is interpreted as the maximum allowed time
          for each network operation during connection setup to another
          Erlang node. The maximum allowed value is <c>120</c>. If higher values
          are specified, <c>120</c> is used. Default is 7 seconds if the variable
          is not specified, or if the value is incorrect (for example, not a number).</p>
        <p>Notice that this value does not limit the total connection
          setup time, but rather each individual network operation during
          the connection setup and handshake.</p>
      </item>
      <tag><c>net_ticktime = TickTime</c></tag>
      <item>
        <marker id="net_ticktime"></marker>
        <p>Specifies the <c>net_kernel</c> tick time. <c>TickTime</c>
          is specified in seconds. Once every <c>TickTime/4</c> second, all
          connected nodes are ticked (if anything else is written
          to a node). If nothing is received from another node
          within the last four tick times, that node is considered
          to be down. This ensures that nodes that are not responding,
          for reasons such as hardware errors, are considered to be
          down.</p>
        <p>The time <c>T</c>, in which a node that is not responding is
          detected, is calculated as <c><![CDATA[MinT < T < MaxT]]></c>, where:</p>
        <code type="none">
MinT = TickTime - TickTime / 4
MaxT = TickTime + TickTime / 4</code>
        <p><c>TickTime</c> defaults to <c>60</c> (seconds). Thus,
          <c><![CDATA[45 < T < 75]]></c> seconds.</p>
        <p>Notice that <em>all</em> communicating nodes are to have the <em>same</em>
          <c>TickTime</c> value specified.</p>
        <p>Normally, a terminating node is detected immediately.</p>
      </item>
      <tag><c>shutdown_timeout = integer() | infinity</c></tag>
      <item>
        <p>Specifies the time <c>application_controller</c> waits
          for an application to terminate during node shutdown. If the
          timer expires, <c>application_controller</c> brutally
          kills <c>application_master</c> of the hanging
          application. If this parameter is undefined, it defaults
          to <c>infinity</c>.</p>
      </item>
      <tag><c>sync_nodes_mandatory = [NodeName]</c></tag>
      <item>
        <p>Specifies which other nodes that <em>must</em> be alive
          for this node to start properly. If some node in the list
          does not start within the specified time, this node does not
          start either. If this parameter is undefined, it defaults to
          <c>[]</c>.</p>
      </item>
      <tag><c>sync_nodes_optional = [NodeName]</c></tag>
      <item>
        <p>Specifies which other nodes that <em>can</em> be alive
          for this node to start properly. If some node in this list
          does not start within the specified time, this node starts
          anyway. If this parameter is undefined, it defaults to
          the empty list.</p>
      </item>
      <tag><c>sync_nodes_timeout = integer() | infinity</c></tag>
      <item>
        <p>Specifies the time (in milliseconds) that this node
          waits for the mandatory and optional nodes to start. If
          this parameter is undefined, no node synchronization is
          performed. This option ensures that <c>global</c> is
          synchronized.</p>
      </item>
      <tag><c>start_dist_ac = true | false</c></tag>
      <item>
        <p>Starts the <c>dist_ac</c> server if the parameter is
          <c>true</c>. This parameter is to be set to <c>true</c> for
          systems using distributed applications.</p>
        <p>Defaults to <c>false</c>.  If this parameter is
          undefined, the server is started if parameter
          <c>distributed</c> is set.</p>
      </item>
      <tag><c>start_boot_server = true | false</c></tag>
      <item>
        <p>Starts the <c>boot_server</c> if the parameter is <c>true</c>
          (see <seealso marker="erl_boot_server"><c>erl_boot_server(3)</c></seealso>).
	  This parameter is to be set to <c>true</c> in an embedded system
	  using this service.</p>
        <p>Defaults to <c>false</c>.</p>
      </item>
      <tag><c>boot_server_slaves = [SlaveIP]</c></tag>
      <item>
        <p>If configuration parameter <c>start_boot_server</c> is
          <c>true</c>, this parameter can be used to initialize
          <c>boot_server</c> with a list of slave IP addresses:</p>
	<p>
          <c>SlaveIP = string() | atom | {integer(),integer(),integer(),integer()}</c>,</p>
        <p>where <c><![CDATA[0 <= integer() <=255]]></c>.</p>
        <p>Examples of <c>SlaveIP</c> in atom, string, and tuple form:</p>
	<p><c>'150.236.16.70', "150,236,16,70", {150,236,16,70}</c>.</p>
        <p>Defaults to <c>[]</c>.</p>
      </item>
      <tag><c>start_disk_log = true | false</c></tag>
      <item>
        <p>Starts the <c>disk_log_server</c> if the parameter is
          <c>true</c> (see <seealso marker="disk_log"><c>disk_log(3)</c></seealso>).
	  This parameter is to be set to <c>true</c> in an embedded system
	  using this service.</p>
        <p>Defaults to <c>false</c>.</p>
      </item>
      <tag><c>start_pg2 = true | false</c></tag>
      <item>
        <marker id="start_pg2"></marker>
        <p>Starts the <c>pg2</c> server (see
	  <seealso marker="pg2"><c>pg2(3)</c></seealso>) if
          the parameter is <c>true</c>. This parameter is to be set to
          <c>true</c> in an embedded system that uses this service.</p>
        <p>Defaults to <c>false</c>.</p>
      </item>
      <tag><c>start_timer = true | false</c></tag>
      <item>
        <p>Starts the <c>timer_server</c> if the parameter is
          <c>true</c> (see <seealso marker="stdlib:timer"><c>timer(3)</c></seealso>).
	  This parameter is to be set to <c>true</c> in an embedded system
	  using this service.</p>
        <p>Defaults to <c>false</c>.</p>
      </item>
      <tag><c>shell_history = enabled | disabled </c></tag>
      <item>
        <p>Specifies whether shell history should be logged to disk
           between usages of <c>erl</c>.</p>
      </item>
      <tag><c>shell_history_drop = [string()]</c></tag>
      <item>
        <p>Specific log lines that should not be persisted. For
           example <c>["q().", "init:stop()."]</c> will allow to
           ignore commands that shut the node down. Defaults to
           <c>[]</c>.</p>
      </item>
      <tag><c>shell_history_file_bytes = integer()</c></tag>
      <item>
        <p>how many bytes the shell should remember. By default, the
           value is set to 512kb, and the minimal value is 50kb.</p>
      </item>
      <tag><c>shell_history_path = string()</c></tag>
      <item>
        <p>Specifies where the shell history files will be stored.
           defaults to the user's cache directory as returned by
           <c>filename:basedir(user_cache, "erlang-history")</c>.</p>
      </item>
      <tag><c>shutdown_func = {Mod, Func}</c></tag>
      <item>
        <p>Where:</p>
        <list type="bulleted">
          <item><c>Mod = atom()</c></item>
          <item><c>Func = atom()</c></item>
        </list>
        <p>Sets a function that <c>application_controller</c> calls
          when it starts to terminate. The function is called as
          <c>Mod:Func(Reason)</c>, where <c>Reason</c> is the terminate
          reason for <c>application_controller</c>, and it must
          return as soon as possible for <c>application_controller</c>
          to terminate properly.</p>
      </item>
      <tag><c>source_search_rules = [DirRule] | [SuffixRule] </c></tag>
      <item>
	<marker id="source_search_rules"></marker>
        <p>Where:</p>
        <list type="bulleted">
          <item><c>DirRule = {ObjDirSuffix,SrcDirSuffix}</c></item>
          <item><c>SuffixRule = {ObjSuffix,SrcSuffix,[DirRule]}</c></item>
          <item><c>ObjDirSuffix = string()</c></item>
          <item><c>SrcDirSuffix = string()</c></item>
          <item><c>ObjSuffix = string()</c></item>
          <item><c>SrcSuffix = string()</c></item>
        </list>
        <p>Specifies a list of rules for use by <c>filelib:find_file/2</c> and
          <c>filelib:find_source/2</c>. If this is set to some other value
          than the empty list, it replaces the default rules. Rules can be
          simple pairs of directory suffixes, such as <c>{"ebin",
          "src"}</c>, which are used by <c>filelib:find_file/2</c>, or
          triples specifying separate directory suffix rules depending on
          file name extensions, for example <c>[{".beam", ".erl", [{"ebin",
          "src"}]}</c>, which are used by <c>filelib:find_source/2</c>. Both
          kinds of rules can be mixed in the list.</p>
      </item>
    </taglist>
  </section>

  <section>
    <title>See Also</title>
    <p><seealso marker="app"><c>app(4)</c></seealso>,
      <seealso marker="application"><c>application(3)</c></seealso>,
      <seealso marker="code"><c>code(3)</c></seealso>,
      <seealso marker="disk_log"><c>disk_log(3)</c></seealso>,
      <seealso marker="erl_boot_server"><c>erl_boot_server(3)</c></seealso>,
      <seealso marker="erl_ddll"><c>erl_ddll(3)</c></seealso>,
      <seealso marker="error_logger"><c>error_logger(3)</c></seealso>,
      <seealso marker="file"><c>file(3)</c></seealso>,
      <seealso marker="global"><c>global(3)</c></seealso>,
      <seealso marker="global_group"><c>global_group(3)</c></seealso>,
      <seealso marker="heart"><c>heart(3)</c></seealso>,
      <seealso marker="inet"><c>inet(3)</c></seealso>,
      <seealso marker="net_kernel"><c>net_kernel(3)</c></seealso>,
      <seealso marker="os"><c>os(3)</c></seealso>,
      <seealso marker="pg2"><c>pg2(3)</c></seealso>,
      <seealso marker="rpc"><c>rpc(3)</c></seealso>,
      <seealso marker="seq_trace"><c>seq_trace(3)</c></seealso>,
      <seealso marker="user"><c>user(3)</c></seealso>,
      <seealso marker="stdlib:timer"><c>timer(3)</c></seealso></p>
  </section>
</appref>