Example #1
0
File: exec.c Project: srfrog/epic5
/*
 * close_in:  When we are finished with the process but still want the
 * rest of its output, we close its input, and hopefully it will get the
 * message and close up shop.
 */
static void 	exec_close_in (int idx)
{
	Process *proc;

	if (valid_process_index(idx) == 0)
		return;

	proc = process_list[idx];
	if (proc->p_stdin != -1)
		proc->p_stdin = new_close(proc->p_stdin);
}
Example #2
0
File: exec.c Project: srfrog/epic5
/*
 * is_valid_process: tells me if the spec is a process that is either
 * running or still has not closed its pipes, or both.
 */
int		is_valid_process (const char *arg)
{
	if (!arg || *arg != '%')
		return -1;

	arg++;
	if (is_number(arg) && valid_process_index(my_atol(arg)))
		return my_atol(arg);
	else
		return logical_to_index(arg);

	return -1;
}
Example #3
0
File: exec.c Project: srfrog/epic5
/*
 * close_out:  When we are done sending to a process sometimes we have to 
 * close our stdout before they will do their thing and send us data back
 * to stdin.  
 */
static void 	exec_close_out (int idx)
{
	Process *proc;

	if (valid_process_index(idx) == 0)
		return;

	proc = process_list[idx];
	if (proc->p_stdout != -1)
		proc->p_stdout = new_close(proc->p_stdout);
	if (proc->p_stderr != -1)
		proc->p_stderr = new_close(proc->p_stderr);

	proc->dumb = 1;
}
Example #4
0
File: exec.c Project: srfrog/epic5
/*
 * text_to_process: sends the given text to the given process.  If the given
 * process index is not valid, an error is reported and 1 is returned.
 * Otherwise 0 is returned. 
 * Added show, to remove some bad recursion, phone, april 1993
 */
int 		text_to_process (int proc_index, const char *text, int show)
{
	Process	*proc;
	char *	my_buffer;
	size_t	size;
	char	logical_name[1024];
	const char *recoded_text;
	char *	extra = NULL;

	if (valid_process_index(proc_index) == 0)
		return 1;

	proc = process_list[proc_index];

	if (show)
	{
		int	l = message_setall(proc->refnum, NULL, LEVEL_OTHER);
		put_it("%s%s", get_prompt_by_refnum(proc->refnum), text);
		pop_message_from(l);
	}

	size = strlen(text) + 2;
	my_buffer = alloca(size);
	snprintf(my_buffer, size, "%s\n", text);

	index_to_target(proc_index, logical_name, sizeof(logical_name));
	recoded_text = outbound_recode(logical_name, proc->server, my_buffer, &extra);
	if (write(proc->p_stdin, recoded_text, strlen(recoded_text)) <= 0)
	{
		yell("Was unable to write text %s to process %d",
			text, proc_index);
	}
	new_free(&extra);

	set_prompt_by_refnum(proc->refnum, empty_string);
	return (0);
}
Example #5
0
/*
 * text_to_process: sends the given text to the given process.  If the given
 * process index is not valid, an error is reported and 1 is returned.
 * Otherwise 0 is returned. 
 * Added show, to remove some bad recursion, phone, april 1993
 */
int 		text_to_process (int proc_index, const char *text, int show)
{
	Process	*	proc;
	char	*	my_buffer;
	size_t	size;

	if (valid_process_index(proc_index) == 0)
		return 1;

	proc = process_list[proc_index];

	message_to(proc->refnum);
	if (show)
		put_it("%s%s", get_prompt_by_refnum(proc->refnum), text);
	message_to(-1);

	size = strlen(text) + 2;
	my_buffer = alloca(size);
	snprintf(my_buffer, size, "%s\n", text);
	write(proc->p_stdin, my_buffer, strlen(my_buffer));
	set_prompt_by_refnum(proc->refnum, empty_string);

	return (0);
}