back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2025-08-13 19:19:49 +0300
committerscratko <m@scratko.xyz>2025-08-13 19:19:49 +0300
commit070fe26bb3671df046d0633acc51c9b629fd2f2c (patch)
tree8ef45e52cc5b25a44cc675ed0c77463161308f00
parent42191da2512b6f48f7ccd7765a416a7bc9aeeca6 (diff)
downloadparallel-progs-by-args-master.tar.gz
parallel-progs-by-args-master.tar.bz2
parallel-progs-by-args-master.zip
Added READMEHEADmaster
-rw-r--r--README.md57
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`.