mike121 pushed a commit to branch main
in repository guile.

commit 2e51d3fa26e492c00e88b47005568a4c21582dfe
Author: Michael Gran <spk...@yahoo.com>
AuthorDate: Tue Jun 20 15:28:09 2023 -0700

    In piped_process, replace dprintf with more portable functions
    
    dprint is missing on many non-glic platforms
    
    * libguile/posix.c (piped_process): replace dprintf with sprintf+write
---
 libguile/posix.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 6e9fd4b7c..c8bbb0f83 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1537,6 +1537,7 @@ piped_process (pid_t *pid, SCM prog, SCM args, SCM from, 
SCM to)
   int c2p[2] = {0, 0}; /* Child to parent.  */
   int p2c[2] = {0, 0}; /* Parent to child.  */
   int in = -1, out = -1, err = -1;
+  char errbuf[200];
   char *exec_file;
   char **exec_argv;
   char **exec_env = environ;
@@ -1607,8 +1608,20 @@ piped_process (pid_t *pid, SCM prog, SCM args, SCM from, 
SCM to)
       default:    /* ENOENT, etc. */
         /* Report the error on the console (before switching to
            'posix_spawn', the child process would do exactly that.)  */
-        dprintf (err, "In execvp of %s: %s\n", exec_file,
-                 strerror (errno_save));
+        snprintf (errbuf, sizeof (errbuf), "In execvp of %s: %s\n", exec_file,
+                  strerror (errno_save));
+        int n, i = 0;
+        int len = strlen (errbuf);
+        do
+          {
+            n = write (err, errbuf + i, len);
+            if (n <= 0)
+              break;
+            len -= n;
+            i += n;
+          }
+        while (len > 0);
+
       }
 
   free (exec_file);

Reply via email to