C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
redirection.h File Reference
#include "shelltypes.h"

Functions

int handle_redirection (struct command *cmd)
 Handles redirections for a command.
 

Function Documentation

◆ handle_redirection()

int handle_redirection ( struct command * cmd)

Handles redirections for a command.

Parses the command's arguments and sets the file descriptors for input, output, and error. If a file is not found, the function will print an error message and return -1.

Command arguments are modified in place to remove the redirection symbols and the file names. The file descriptors must be standard input/output/error. Otherwise, the function will print an error message and return -1.

Parameters
cmd
Returns
0 on success, -1 on error