File 1232-Add-start_epmd-command-line-option.patch of Package erlang

From 34f853950685e4e7ab38f30fc3f17a6beac13349 Mon Sep 17 00:00:00 2001
From: Magnus Henoch <magnus@erlang-solutions.com>
Date: Wed, 20 Apr 2016 14:40:39 +0100
Subject: [PATCH 1/3] Add -start_epmd command line option

Add a command line option that lets you disable automatic starting of
epmd when starting a distributed node.

This differs from the undocumented setting -no_epmd, in that it does
not affect the starting of an erl_epmd process within
erl_distribution: the newly started node will expect an epmd instance
to have been started previously.
---
 erts/doc/src/erl.xml      | 18 +++++++++++++++++-
 erts/etc/common/erlexec.c | 21 ++++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/erts/doc/src/erl.xml b/erts/doc/src/erl.xml
index 1bbde7f..e63928d 100644
--- a/erts/doc/src/erl.xml
+++ b/erts/doc/src/erl.xml
@@ -338,7 +338,8 @@
           <seealso marker="kernel:net_kernel">net_kernel(3)</seealso>.
           It is also ensured that <c><![CDATA[epmd]]></c> runs on the current host
           before Erlang is started. See
-          <seealso marker="epmd">epmd(1)</seealso>.</p>
+          <seealso marker="epmd">epmd(1)</seealso> and the
+          <seealso marker="#start_epmd"><c>-start_epmd</c></seealso> option.</p>
         <p>The name of the node will be <c><![CDATA[Name@Host]]></c>, where
           <c><![CDATA[Host]]></c> is the fully qualified host name of the current
           host. For short names, use the <c><![CDATA[-sname]]></c> flag instead.</p>
@@ -463,6 +464,21 @@
           flag and those running with the <c><![CDATA[-name]]></c> flag, as node
           names must be unique in distributed Erlang systems.</p>
       </item>
+      <tag><marker id="start_epmd"/><c>-start_epmd true | false</c></tag>
+      <item>
+
+        <p>Specifies whether Erlang should start
+          <seealso marker="epmd">epmd</seealso> on startup. By default
+          this is <c>true</c>, but if you prefer to start epmd
+          manually, set this to <c>false</c>.</p>
+
+        <p>This only applies if Erlang is started as a distributed node,
+          i.e. if <c>-name</c> or <c>-sname</c> is specified. Otherwise,
+          epmd is not started even if <c>-start_epmd true</c> is given.</p>
+
+        <p>Note that a distributed node will fail to start if epmd is
+          not running.</p>
+      </item>
       <tag><marker id="smp"/><c><![CDATA[-smp [enable|auto|disable]]]></c></tag>
       <item>
         <p><c>-smp enable</c> and <c>-smp</c> starts the Erlang runtime
diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c
index 42da05b..2b2e0e4 100644
--- a/erts/etc/common/erlexec.c
+++ b/erts/etc/common/erlexec.c
@@ -195,6 +195,7 @@ static char *plusz_val_switches[] = {
 #endif
 
 void usage(const char *switchname);
+static void usage_format(char *format, ...);
 void start_epmd(char *epmd);
 void error(char* format, ...);
 
@@ -795,6 +796,24 @@ int main(int argc, char **argv)
 			    get_start_erl_data((char *) NULL);
 		    }
 #endif
+		    else if (strcmp(argv[i], "-start_epmd") == 0) {
+			if (i+1 >= argc)
+			    usage("-start_epmd");
+
+			if (strcmp(argv[i+1], "true") == 0) {
+			    /* The default */
+			    no_epmd = 0;
+			}
+			else if (strcmp(argv[i+1], "false") == 0) {
+			    no_epmd = 1;
+			}
+			else
+			    usage_format("Expected boolean argument for \'-start_epmd\'.\n");
+
+			add_arg(argv[i]);
+			add_arg(argv[i+1]);
+			i++;
+		    }
 		    else
 			add_arg(argv[i]);
 		
@@ -1173,7 +1192,7 @@ usage_aux(void)
 	  "]"
 #endif
 	  "] "
-	  "[-make] [-man [manopts] MANPAGE] [-x] [-emu_args] "
+	  "[-make] [-man [manopts] MANPAGE] [-x] [-emu_args] [-start_epmd BOOLEAN] "
 	  "[-args_file FILENAME] [+A THREADS] [+a SIZE] [+B[c|d|i]] [+c [BOOLEAN]] "
 	  "[+C MODE] [+h HEAP_SIZE_OPTION] [+K BOOLEAN] "
 	  "[+l] [+M<SUBSWITCH> <ARGUMENT>] [+P MAX_PROCS] [+Q MAX_PORTS] "
-- 
2.1.4

openSUSE Build Service is sponsored by