|
myshell 2.0.0
|
Execution related utilities. More...
Functions | |
| int | msh_exec_script (const char *path) |
| Executes a script line by line. | |
| int | msh_execve (char **argv) |
| Executes a command. | |
| int | msh_exec_simple (simple_command &cmd, int pipe_in=STDIN_FILENO, int pipe_out=STDOUT_FILENO, int flags=0) |
| Executes a simple command. | |
| int | msh_exec_internal (command &cmd, int in, int out, int flags) |
| Internal command execution function. | |
Variables | |
| int | exec_line_no = 0 |
| The current line number of the script being executed. | |
| std::string | exec_path |
| The path to the script being executed. | |
Execution related utilities.
| int msh_exec_internal | ( | command & | cmd, |
| int | in, | ||
| int | out, | ||
| int | flags ) |
Internal command execution function.
Delegates the execution to the appropriate function based on the command type holded by the cmd.cmd variant object.
| cmd | The command to execute. |
| in | File descriptor to use as stdin. |
| out | File descriptor to use as stdout. |
| flags | Flags to pass to the command. |
| int msh_exec_script | ( | const char * | path | ) |
Executes a script line by line.
exec_path and exec_line_no are set for error_log().
| path | Path to the script. |
| int msh_exec_simple | ( | simple_command & | cmd, |
| int | pipe_in = STDIN_FILENO, | ||
| int | pipe_out = STDOUT_FILENO, | ||
| int | flags = 0 ) |
Executes a simple command.
| cmd | The command to execute. |
| pipe_in | File descriptor to use as stdin. |
| pipe_out | File descriptor to use as stdout. |
| flags | Flags to pass to the command. |
If the command is a builtin, it is executed directly. Otherwise, it is executed using msh_execve().
If either pipe_in or pipe_out is not STDIN_FILENO or STDOUT_FILENO respectively, the command is not a builtin, or the command is executed asynchronously, the command will be executed in a forked process.
If either ASYNC or FORK_NO_WAIT is set in flags, the parent process returns immediately. One should take care of the child process by calling wait_for_process() or reap_children() explicitly if needed.
| int msh_execve | ( | char ** | argv | ) |
Executes a command.
| argv | Array of arguments. |
If command contains a slash, it is executed directly, supposing it is a full path to the executable. Otherwise, the command is searched in the PATH environment variable using execvpe(). If execve() fails and errno is ENOEXEC, the command is treated as a script and executed using msh_exec_script().
| int exec_line_no = 0 |
The current line number of the script being executed.
Undefined if no script is being executed.
| std::string exec_path |
The path to the script being executed.
Undefined if no script is being executed.