File otp_src_18.2.2-erlexec.patch of Package erlang
diff -Ndurp otp_src_18.2.2/erts/etc/common/erlexec.c otp_src_18.2.2-erlexec/erts/etc/common/erlexec.c
--- otp_src_18.2.2/erts/etc/common/erlexec.c 2016-01-08 14:09:37.000000000 +0200
+++ otp_src_18.2.2-erlexec/erts/etc/common/erlexec.c 2016-01-24 06:08:27.182896664 +0200
@@ -31,6 +31,9 @@
#include "erl_driver.h"
#include <stdlib.h>
#include <stdarg.h>
+#ifndef __WIN32__
+#include <unistd.h>
+#endif
#include "erl_misc_utils.h"
#ifdef __WIN32__
@@ -565,14 +568,17 @@ int main(int argc, char **argv)
erts_cpu_info_destroy(cpuinfo);
cpuinfo = NULL;
- if (malloc_lib) {
- if (strcmp(malloc_lib, "libc") != 0)
- usage("+MYm");
- }
- emu = add_extra_suffixes(emu, emu_type);
- emu_name = strsave(emu);
- erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s" BINARY_EXT, bindir, emu);
+ if (malloc_lib && strcmp(malloc_lib, "libc") != 0)
+ usage("+MYm");
+
+ emu_name = add_extra_suffixes(emu, emu_type);
+ i = erts_snprintf(tmpStr, sizeof(tmpStr), "%s" DIRSEP "%s" BINARY_EXT, bindir, emu_name);
+#ifndef __WIN32__
+ if (emu_type == EMU_TYPE_SMP && access(tmpStr, X_OK))
+ tmpStr[i - strlen(SMP_SUFFIX)] = '\0';
+#endif
emu = strsave(tmpStr);
+ emu_name = emu + i - strlen(emu_name);
add_Eargs(emu); /* Will be argv[0] -- necessary! */