Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

exec.h File Reference

Prototypes for functions for executing a program. More...

#include <wchar.h>
#include "proc.h"
#include "util.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PIPE_ERROR   _(L"An error occurred while setting up pipe")
 pipe redirection error message

Functions

void exec (job_t *j)
 Execute the processes specified by j.
__warn_unused int exec_subshell (const wchar_t *cmd, array_list_t *l)
 Evaluate the expression cmd in a subshell, add the outputs into the list l.
void exec_close (int fd)
 Loops over close until thesyscall was run without beeing interrupted.
int exec_pipe (int fd[2])
 Call pipe(), and add resulting fds to open_fds, the list of opend file descriptors for pipes.


Detailed Description

Prototypes for functions for executing a program.


Function Documentation

void exec job_t j  ) 
 

Execute the processes specified by j.

I've put a fair bit of work into making builtins behave like other programs as far as pipes are concerned. Unlike i.e. bash, builtins can pipe to other builtins with arbitrary amounts of data, and so on. To do this, after a builtin is run in the real process, it forks and a dummy process is created, responsible for writing the output of the builtin. This is surprisingly cheap on my computer, probably because of the marvels of copy on write forking.

This rule is short circuted in the case where a builtin does not output to a pipe and does in fact not output anything. The speed improvement from this optimization is not noticable on a normal computer/OS in regular use, but the promiscous amounts of forking that resulted was responsible for a huge slowdown when using Valgrind as well as when doing complex command-specific completions.

void exec_close int  fd  ) 
 

Loops over close until thesyscall was run without beeing interrupted.

Thenremoves the fd from the open_fds list.

__warn_unused int exec_subshell const wchar_t *  cmd,
array_list_t l
 

Evaluate the expression cmd in a subshell, add the outputs into the list l.

On return, the status flag as returned bu proc_gfet_last_status will not be changed.

Parameters:
cmd the command to execute
l The list to insert output into.If l is zero, the output will be discarded.
Returns:
the status of the last job to exit, or -1 if en error was encountered.


Generated on Sun Jan 13 02:52:45 2008 for fish by  doxygen 1.4.4