diff options
author | Michael Gran <spk121@yahoo.com> | 2023-06-20 15:28:09 -0700 |
---|---|---|
committer | Michael Gran <spk121@yahoo.com> | 2025-03-22 21:33:33 -0700 |
commit | 2e51d3fa26e492c00e88b47005568a4c21582dfe (patch) | |
tree | 317aad09695ff9e565fd77aff94b63bf23b9071c /libguile/posix.c | |
parent | 9c86c5936e6eda65e4e38e95d582ee0d2360af47 (diff) | |
download | guile-2e51d3fa26e492c00e88b47005568a4c21582dfe.tar.gz |
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
Diffstat (limited to 'libguile/posix.c')
-rw-r--r-- | libguile/posix.c | 17 |
1 files 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); |