From c2e6b07b357f3173fdc9f14d0b5841761634b821 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 29 Nov 2005 20:12:06 +1000 Subject: [PATCH] Try to report IO redirection errors resulting from redirection stderr darcs-hash:20051129101206-ac50b-970569a8b710d74b6e16a3c09b8848618cec4a7e.gz --- exec.c | 18 +++++++++++------- wildcard.c | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/exec.c b/exec.c index a74319bb1..739e2bf1e 100644 --- a/exec.c +++ b/exec.c @@ -261,17 +261,13 @@ static void handle_child_io( io_data_t *io ) free_fd( io, io->fd ); } - /* - We don't mind if this fails, it is just a speculative close - to make sure no unexpected untracked fd causes us to fail - */ - close(io->fd); - switch( io->io_mode ) { case IO_CLOSE: + close(io->fd); break; case IO_FILE: + { if( (tmp=wopen( io->param1.filename, io->param2.flags, 0777 ) )==-1 ) { @@ -284,6 +280,8 @@ static void handle_child_io( io_data_t *io ) } else if( tmp != io->fd) { + close(io->fd); + if(dup2( tmp, io->fd ) == -1 ) { debug( 1, @@ -295,7 +293,11 @@ static void handle_child_io( io_data_t *io ) exec_close( tmp ); } break; + } + case IO_FD: + { + close(io->fd); /* debug( 3, L"Redirect fd %d in process %ls (%d) from fd %d", io->fd, p->actual_cmd, @@ -311,10 +313,12 @@ static void handle_child_io( io_data_t *io ) exit(1); } break; - + } + case IO_BUFFER: case IO_PIPE: { + close(io->fd); /* debug( 3, L"Pipe fd %d in process %ls (%d) (Through fd %d)", io->fd, diff --git a/wildcard.c b/wildcard.c index e99196770..36f86fb69 100644 --- a/wildcard.c +++ b/wildcard.c @@ -73,7 +73,7 @@ static int wildcard_match2( const wchar_t *str, /* Ignore hidden file */ if( is_first && *str == L'.' ) return 0; - + /* Try all submatches */ do {