diff options
author | 2006-06-21 19:54:30 +1000 | |
---|---|---|
committer | 2006-06-21 19:54:30 +1000 | |
commit | 3ddd5e59810d0d1642a061a6342811a8be7a5251 (patch) | |
tree | db8ed435f7a584c3c8643445c17c95b4f7c04734 /exec.c | |
parent | b016438c08877cb3b24808d260397a8aa8fe49ce (diff) |
Check exit status of close and fclose in a few extra places
darcs-hash:20060621095430-ac50b-52afcee91b856f706d6df6bcf2e3a6bc7d746e40.gz
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -86,9 +86,10 @@ void exec_close( int fd ) { debug( 1, FD_ERROR, fd ); wperror( L"close" ); + break; } } - + if( open_fds ) { for( i=0; i<al_get_count( open_fds ); i++ ) @@ -260,7 +261,11 @@ static int handle_child_io( io_data_t *io, int exit_on_error ) switch( io->io_mode ) { case IO_CLOSE: - close(io->fd); + if( close(io->fd) ) + { + debug( 0, _(L"Failed to close file descriptor %d"), io->fd ); + wperror( L"close" ); + } break; case IO_FILE: { @@ -283,8 +288,12 @@ static int handle_child_io( io_data_t *io, int exit_on_error ) } else if( tmp != io->fd) { + /* + This call will sometimes fail, but that is ok, + this is just a precausion. + */ close(io->fd); - + if(dup2( tmp, io->fd ) == -1 ) { debug( 1, @@ -307,6 +316,10 @@ static int handle_child_io( io_data_t *io, int exit_on_error ) case IO_FD: { + /* + This call will sometimes fail, but that is ok, + this is just a precausion. + */ close(io->fd); if( dup2( io->param1.old_fd, io->fd ) == -1 ) @@ -332,6 +345,10 @@ static int handle_child_io( io_data_t *io, int exit_on_error ) { int fd_to_dup = io->fd; + /* + This call will sometimes fail, but that is ok, + this is just a precausion. + */ close(io->fd); if( dup2( io->param1.pipe_fd[fd_to_dup?1:0], io->fd ) == -1 ) |