mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-29 14:21:24 -03:00
convert narrow stderr output to wide forms
On some platforms, notably GNU libc, you cannot mix narrow and wide stdio functions on a stream like stdout or stderr. Doing so will drop the output of one or the other. This change makes all output to the stderr stream consistently use the wide forms. This change also converts some fprintf(stderr,...) calls to debug() calls where appropriate. Fixes #3692
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#if FISH_USE_POSIX_SPAWN
|
||||
#include <spawn.h>
|
||||
#endif
|
||||
#include <wchar.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "exec.h"
|
||||
@@ -141,7 +142,7 @@ static int handle_child_io(const io_chain_t &io_chain) {
|
||||
|
||||
switch (io->io_mode) {
|
||||
case IO_CLOSE: {
|
||||
if (log_redirections) fprintf(stderr, "%d: close %d\n", getpid(), io->fd);
|
||||
if (log_redirections) fwprintf(stderr, L"%d: close %d\n", getpid(), io->fd);
|
||||
if (close(io->fd)) {
|
||||
debug_safe_int(0, "Failed to close file descriptor %s", io->fd);
|
||||
safe_perror("close");
|
||||
@@ -180,7 +181,7 @@ static int handle_child_io(const io_chain_t &io_chain) {
|
||||
case IO_FD: {
|
||||
int old_fd = static_cast<const io_fd_t *>(io)->old_fd;
|
||||
if (log_redirections)
|
||||
fprintf(stderr, "%d: fd dup %d to %d\n", getpid(), old_fd, io->fd);
|
||||
fwprintf(stderr, L"%d: fd dup %d to %d\n", getpid(), old_fd, io->fd);
|
||||
|
||||
// This call will sometimes fail, but that is ok, this is just a precausion.
|
||||
close(io->fd);
|
||||
@@ -200,14 +201,14 @@ static int handle_child_io(const io_chain_t &io_chain) {
|
||||
// fd). If it's 1, we're connecting to the write end (second pipe fd).
|
||||
unsigned int write_pipe_idx = (io_pipe->is_input ? 0 : 1);
|
||||
#if 0
|
||||
debug( 0, L"%ls %ls on fd %d (%d %d)", write_pipe?L"write":L"read",
|
||||
(io->io_mode == IO_BUFFER)?L"buffer":L"pipe", io->fd, io->pipe_fd[0],
|
||||
io->pipe_fd[1]);
|
||||
debug(0, L"%ls %ls on fd %d (%d %d)", write_pipe?L"write":L"read",
|
||||
(io->io_mode == IO_BUFFER)?L"buffer":L"pipe", io->fd, io->pipe_fd[0],
|
||||
io->pipe_fd[1]);
|
||||
#endif
|
||||
if (log_redirections)
|
||||
fprintf(stderr, "%d: %s dup %d to %d\n", getpid(),
|
||||
io->io_mode == IO_BUFFER ? "buffer" : "pipe",
|
||||
io_pipe->pipe_fd[write_pipe_idx], io->fd);
|
||||
fwprintf(stderr, L"%d: %s dup %d to %d\n", getpid(),
|
||||
io->io_mode == IO_BUFFER ? "buffer" : "pipe",
|
||||
io_pipe->pipe_fd[write_pipe_idx], io->fd);
|
||||
if (dup2(io_pipe->pipe_fd[write_pipe_idx], io->fd) != io->fd) {
|
||||
debug_safe(1, LOCAL_PIPE_ERROR);
|
||||
safe_perror("dup2");
|
||||
|
||||
Reference in New Issue
Block a user