mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Fix file descriptor leakage from completion pager
darcs-hash:20061112121613-ac50b-209d42c06401faf675ff123236823dcaa651d6f7.gz
This commit is contained in:
parent
80759ee03f
commit
ec43090c16
4 changed files with 15 additions and 17 deletions
2
exec.c
2
exec.c
|
@ -704,7 +704,7 @@ void exec( job_t *j )
|
|||
|
||||
if( input_redirect &&
|
||||
(input_redirect->io_mode == IO_BUFFER) &&
|
||||
input_redirect->param3.is_input )
|
||||
input_redirect->is_input )
|
||||
{
|
||||
/*
|
||||
Input redirection - create a new gobetween process to take
|
||||
|
|
16
io.c
16
io.c
|
@ -53,9 +53,8 @@ Utilities for io redirection.
|
|||
|
||||
void io_buffer_read( io_data_t *d )
|
||||
{
|
||||
|
||||
exec_close(d->param1.pipe_fd[1] );
|
||||
|
||||
|
||||
if( d->io_mode == IO_BUFFER )
|
||||
{
|
||||
/* if( fcntl( d->param1.pipe_fd[0], F_SETFL, 0 ) )
|
||||
|
@ -108,7 +107,7 @@ io_data_t *io_buffer_create( int is_input )
|
|||
buffer_redirect->io_mode=IO_BUFFER;
|
||||
buffer_redirect->next=0;
|
||||
buffer_redirect->param2.out_buffer= malloc( sizeof(buffer_t));
|
||||
buffer_redirect->param3.is_input = is_input;
|
||||
buffer_redirect->is_input = is_input;
|
||||
b_init( buffer_redirect->param2.out_buffer );
|
||||
buffer_redirect->fd=is_input?0:1;
|
||||
|
||||
|
@ -135,7 +134,16 @@ io_data_t *io_buffer_create( int is_input )
|
|||
|
||||
void io_buffer_destroy( io_data_t *io_buffer )
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
If this is an input buffer, then io_read_buffer will not have
|
||||
been called, and we need to close the output fd as well.
|
||||
*/
|
||||
if( io_buffer->is_input )
|
||||
{
|
||||
exec_close(io_buffer->param1.pipe_fd[1] );
|
||||
}
|
||||
|
||||
exec_close( io_buffer->param1.pipe_fd[0] );
|
||||
|
||||
/*
|
||||
|
|
11
io.h
11
io.h
|
@ -45,16 +45,7 @@ typedef struct io_data
|
|||
} param2
|
||||
;
|
||||
|
||||
union
|
||||
{
|
||||
/**
|
||||
This will be non-zero if this is a buffer of input, not
|
||||
output
|
||||
*/
|
||||
int is_input;
|
||||
}
|
||||
param3;
|
||||
|
||||
int is_input;
|
||||
|
||||
/** Pointer to the next IO redirection */
|
||||
struct io_data *next;
|
||||
|
|
3
reader.c
3
reader.c
|
@ -965,7 +965,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
|||
string_buffer_t msg;
|
||||
wchar_t * prefix_esc;
|
||||
char *foo;
|
||||
|
||||
|
||||
if( !prefix || (wcslen(prefix)==0))
|
||||
prefix_esc = wcsdup(L"\"\"");
|
||||
else
|
||||
|
@ -1026,7 +1026,6 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
|||
|
||||
io_buffer_destroy( out);
|
||||
io_buffer_destroy( in);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue