Adopt posix_spawn (!)

Rewrite IO chains to be a vector of pointers, instead of a linked list
Removed io_transmogrify
This commit is contained in:
ridiculousfish
2012-08-15 00:57:56 -07:00
parent ad6645c48d
commit 61686aff34
27 changed files with 805 additions and 579 deletions

View File

@@ -491,6 +491,51 @@ static void handle_child_status( pid_t pid, int status )
return;
}
process_t::process_t() :
argv_array(),
argv0_narrow(),
type(0),
actual_cmd(),
pid(0),
pipe_write_fd(0),
pipe_read_fd(0),
completed(0),
stopped(0),
status(0),
count_help_magic(0),
next(NULL)
#ifdef HAVE__PROC_SELF_STAT
,last_time(),
last_jiffies(0)
#endif
{
}
process_t::~process_t()
{
if (this->next != NULL)
delete this->next;
}
job_t::job_t(job_id_t jobid) :
command_str(),
command_narrow(),
first_process(NULL),
pgid(0),
tmodes(),
job_id(jobid),
io(),
flags(0)
{
}
job_t::~job_t()
{
if (first_process != NULL)
delete first_process;
io_chain_destroy(this->io);
release_job_id(job_id);
}
/* This is called from a signal handler */
void job_handle_signal ( int signal, siginfo_t *info, void *con )
@@ -808,12 +853,12 @@ static int select_try( job_t *j )
{
fd_set fds;
int maxfd=-1;
io_data_t *d;
FD_ZERO(&fds);
for( d = j->io; d; d=d->next )
for (size_t idx = 0; idx < j->io.size(); idx++)
{
const io_data_t *d = j->io.at(idx);
if( d->io_mode == IO_BUFFER )
{
int fd = d->param1.pipe_fd[0];
@@ -846,14 +891,14 @@ static int select_try( job_t *j )
*/
static void read_try( job_t *j )
{
io_data_t *d, *buff=0;
io_data_t *buff=NULL;
/*
Find the last buffer, which is the one we want to read from
*/
for( d = j->io; d; d=d->next )
for (size_t idx = 0; idx < j->io.size(); idx++)
{
io_data_t *d = j->io.at(idx);
if( d->io_mode == IO_BUFFER )
{
buff=d;