File 2062-erts-Try-fix-erlang-display_string-stdin-.-for-FreeB.patch of Package erlang

From faab417ba56274f0f8f5e88a9edc5d14b1d63003 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Tue, 8 Nov 2022 18:30:26 +0100
Subject: [PATCH 2/3] erts: Try fix erlang:display_string(stdin,..) for FreeBSD

---
 erts/emulator/beam/bif.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 60a7bc69ce..9ac40bab33 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -4210,9 +4210,14 @@ BIF_RETTYPE display_string_2(BIF_ALIST_2)
     }
 #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCSTI)
     else if (ERTS_IS_ATOM_STR("stdin", BIF_ARG_1)) {
-        fd = open("/proc/self/fd/0",0);
+#  if defined(__FreeBSD__)
+        const char stdin_fname[] = "/dev/tty";
+#  else
+        const char stdin_fname[] = "/proc/self/fd/0";
+#  endif
+        fd = open(stdin_fname,0);
         if (fd < 0) {
-            fprintf(stderr,"failed to open %s (%s)\r\n", "/proc/self/fd/0",
+            fprintf(stderr,"failed to open %s (%s)\r\n", stdin_fname,
                     strerror(errno));
             goto error;
         }
-- 
2.35.3

openSUSE Build Service is sponsored by