mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Remove INTERNAL_BUFFER, which was only used by fish_pager
This commit is contained in:
parent
cb40507b7b
commit
e5aa06991e
2 changed files with 5 additions and 74 deletions
67
exec.cpp
67
exec.cpp
|
@ -603,11 +603,7 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
|
|
||||||
debug(4, L"Exec job '%ls' with id %d", j->command_wcstr(), j->job_id);
|
debug(4, L"Exec job '%ls' with id %d", j->command_wcstr(), j->job_id);
|
||||||
|
|
||||||
/* PCA Here we detect the special case of an input buffer redirection, i.e. we want a process to receive data that we hold in a buffer (it is an INPUT for the process, but an output for fish). This is extremely rare: I believe only run_pager creates these and it would be nice to dump it. So we can only have at most one.
|
/* Verify that all IO_BUFFERs are output. We used to support a (single, hacked-in) magical input IO_BUFFER used by fish_pager, but now the claim is that there are no more clients and it is removed. This assertion double-checks that. */
|
||||||
|
|
||||||
It would be great to wean fish_pager off of input redirections so that we can dump input redirections and the INTERNAL_BUFFER process type altogether.
|
|
||||||
*/
|
|
||||||
const io_buffer_t *single_magic_input_redirect = NULL;
|
|
||||||
const io_chain_t all_ios = j->all_io_redirections();
|
const io_chain_t all_ios = j->all_io_redirections();
|
||||||
for (size_t idx = 0; idx < all_ios.size(); idx++)
|
for (size_t idx = 0; idx < all_ios.size(); idx++)
|
||||||
{
|
{
|
||||||
|
@ -616,23 +612,7 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
if ((io->io_mode == IO_BUFFER))
|
if ((io->io_mode == IO_BUFFER))
|
||||||
{
|
{
|
||||||
CAST_INIT(io_buffer_t *, io_buffer, io.get());
|
CAST_INIT(io_buffer_t *, io_buffer, io.get());
|
||||||
if (io_buffer->is_input)
|
assert(! io_buffer->is_input);
|
||||||
{
|
|
||||||
/* We expect to have at most one of these, per the comment above. Note that this assertion is the only reason we don't break out of the loop below */
|
|
||||||
assert(single_magic_input_redirect == NULL && "Should have at most one input IO_BUFFER");
|
|
||||||
|
|
||||||
/*
|
|
||||||
Input redirection - create a new gobetween process to take
|
|
||||||
care of buffering, save the redirection in input_redirect
|
|
||||||
*/
|
|
||||||
process_t *fake = new process_t();
|
|
||||||
fake->type = INTERNAL_BUFFER;
|
|
||||||
fake->pipe_write_fd = STDOUT_FILENO;
|
|
||||||
j->first_process->pipe_read_fd = io->fd;
|
|
||||||
fake->next = j->first_process;
|
|
||||||
j->first_process = fake;
|
|
||||||
single_magic_input_redirect = io_buffer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,11 +1098,6 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
/* We should have handled exec up above */
|
/* We should have handled exec up above */
|
||||||
assert(0 && "INTERNAL_EXEC process found in pipeline, where it should never be. Aborting.");
|
assert(0 && "INTERNAL_EXEC process found in pipeline, where it should never be. Aborting.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INTERNAL_BUFFER:
|
|
||||||
/* Internal buffers are handled in the next switch statement below */
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exec_error)
|
if (exec_error)
|
||||||
|
@ -1214,44 +1189,6 @@ void exec_job(parser_t &parser, job_t *j)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case INTERNAL_BUFFER:
|
|
||||||
{
|
|
||||||
assert(single_magic_input_redirect != NULL);
|
|
||||||
const char *buffer = single_magic_input_redirect->out_buffer_ptr();
|
|
||||||
size_t count = single_magic_input_redirect->out_buffer_size();
|
|
||||||
|
|
||||||
/* We don't have to drain threads here because our child process is simple */
|
|
||||||
if (g_log_forks)
|
|
||||||
{
|
|
||||||
printf("fork #%d: Executing fork for internal buffer for '%ls'\n", g_fork_count, p->argv0() ? p->argv0() : L"(null)");
|
|
||||||
}
|
|
||||||
pid = execute_fork(false);
|
|
||||||
if (pid == 0)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
This is the child process. Write out the
|
|
||||||
contents of the pipeline.
|
|
||||||
*/
|
|
||||||
p->pid = getpid();
|
|
||||||
setup_child_process(j, p, process_net_io_chain);
|
|
||||||
|
|
||||||
exec_write_and_exit(1, buffer, count, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
This is the parent process. Store away
|
|
||||||
information on the child, and possibly give
|
|
||||||
it control over the terminal.
|
|
||||||
*/
|
|
||||||
p->pid = pid;
|
|
||||||
set_child_group(j, p, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case INTERNAL_BUILTIN:
|
case INTERNAL_BUILTIN:
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
12
proc.h
12
proc.h
|
@ -80,12 +80,7 @@ enum process_type_t
|
||||||
/**
|
/**
|
||||||
The exec builtin
|
The exec builtin
|
||||||
*/
|
*/
|
||||||
INTERNAL_EXEC,
|
INTERNAL_EXEC
|
||||||
/**
|
|
||||||
A buffer
|
|
||||||
*/
|
|
||||||
INTERNAL_BUFFER,
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -105,8 +100,7 @@ enum
|
||||||
commands to be evaluated by calling eval. Lastly, this process can
|
commands to be evaluated by calling eval. Lastly, this process can
|
||||||
be the result of an exec command. The role of this process_t is
|
be the result of an exec command. The role of this process_t is
|
||||||
determined by the type field, which can be one of EXTERNAL,
|
determined by the type field, which can be one of EXTERNAL,
|
||||||
INTERNAL_BUILTIN, INTERNAL_FUNCTION, INTERNAL_BLOCK, INTERNAL_EXEC,
|
INTERNAL_BUILTIN, INTERNAL_FUNCTION, INTERNAL_BLOCK, INTERNAL_EXEC.
|
||||||
and INTERNAL_BUFFER.
|
|
||||||
|
|
||||||
The process_t contains information on how the process should be
|
The process_t contains information on how the process should be
|
||||||
started, such as command name and arguments, as well as runtime
|
started, such as command name and arguments, as well as runtime
|
||||||
|
@ -153,7 +147,7 @@ public:
|
||||||
/**
|
/**
|
||||||
Type of process. Can be one of \c EXTERNAL, \c
|
Type of process. Can be one of \c EXTERNAL, \c
|
||||||
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK,
|
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK,
|
||||||
INTERNAL_EXEC, or INTERNAL_BUFFER
|
INTERNAL_EXEC
|
||||||
*/
|
*/
|
||||||
enum process_type_t type;
|
enum process_type_t type;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue