diff options
-rw-r--r-- | README.md | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..41a4080 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Pipeline Executor with Delimiters + +This project implements a small command-line utility in C that executes two +programs connected via a pipeline, using a custom `;;` delimiter to separate +commands. + +## Features + +- Runs two commands, connected with a pipe: + - The first command’s output is sent to the second command’s input. +- Uses `;;` as a custom delimiter to split commands. +- Forks and executes each command using `execvp`. +- Tracks process IDs and command names in a linked list. +- Prints the name of each command that terminates successfully (exit status 0). +- Cleans up dynamically allocated memory for process tracking. + +## How It Works + +1. Parses command-line arguments and splits them into separate commands using `;;` as a delimiter. +2. Creates a pipe before forking processes. +3. For the **first process**: + - Closes the read end of the pipe. + - Redirects stdout to the write end of the pipe. +4. For the **second process**: + - Closes the write end of the pipe. + - Redirects stdin to the read end of the pipe. +5. Executes commands via `execvp`. +6. Waits for all child processes to finish. +7. Prints the names of commands that exited with status `0`. + +## Usage + +Compile: + +```bash +git clone https://git.scratko.xyz/parallel-progs-by-args +cd parallel-progs-by-args +gcc -o pipeline_exec parallel_progs_by_args.c +``` +Run with two commands separated by ;; + +## Example + +```bash +./pipeline_exec echo hello world ;; tr a-z A-Z +``` +This will: + +- Run echo hello world, sending its output into tr a-z A-Z. +- Print the names of commands that executed successfully. + +## Notes + +- Requires at least one `;;` delimiter to separate commands. +- Currently supports exactly **two** commands in the pipeline. +- Command names in output are taken from the original arguments, not from +the executed binary name after `execvp`. |