{"id":18791753,"url":"https://github.com/phip1611/unix_exec_piper","last_synced_at":"2025-04-13T14:23:27.983Z","repository":{"id":57671140,"uuid":"297053841","full_name":"phip1611/unix_exec_piper","owner":"phip1611","description":"unix_exec_piper helps you to exec multiple commands where STDOUT of one process is connected to STDIN of the next process. This is what a shell (like bash) does internally.","archived":false,"fork":false,"pushed_at":"2020-09-20T21:07:45.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T05:24:51.359Z","etag":null,"topics":["exec","fork","pipes","rust","unix"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phip1611.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-20T10:41:15.000Z","updated_at":"2020-09-20T21:07:47.000Z","dependencies_parsed_at":"2022-09-10T14:22:19.321Z","dependency_job_id":null,"html_url":"https://github.com/phip1611/unix_exec_piper","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phip1611%2Funix_exec_piper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phip1611%2Funix_exec_piper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phip1611%2Funix_exec_piper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phip1611%2Funix_exec_piper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phip1611","download_url":"https://codeload.github.com/phip1611/unix_exec_piper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248725623,"owners_count":21151744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exec","fork","pipes","rust","unix"],"created_at":"2024-11-07T21:16:46.006Z","updated_at":"2025-04-13T14:23:27.950Z","avatar_url":"https://github.com/phip1611.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unix_exec_piper: A library written in Rust that execs multiple commands and connects them with pipes.\n\n## TL;DR;\nMy library basically does the functionality that happens when you type `cat file.txt | grep -i | wc -l` \ninto a shell like bash. **unix_exec_piper** does no parsing, but only the actual execution and connection\nbetween the (child) processes via **unix pipes**.\n\nImportant main parts of the library are `pipe.rs` and `lib.rs :: execute_piped_cmd_chain()`.\n\n**The main purpose of this library is educational and to show people who are interested in this how it's done.**\n\nYou might build a shell around this library (if it gets more functionality in the future).\n\n## Basics you need to know\nPlease make yourself familiar with the `UNIX/Posix` concepts:\n- `pipe()`\n- `fork()`\n- `file descriptors` and *\"Everything is a file\"*\n- `exec()`\n\n## Supported features\n- Creating pipes between processes where `STDOUT` of one process gets connected to \n`STDIN` of the next process. \\\n  (`$ cat file.txt | grep -i | wc -l`) \n- I/O redirection into files \\\n  `$ cat \u003c file.txt | grep -i | wc -l \u003e out.txt`\n\n## not (yet) supported features\n- I/O redirection with `STDERR`\n- a lot of other redirection primitives listed here: https://tldp.org/LDP/abs/html/io-redirection.html\n\n## example\nSee `src/bin/example.rs`.\n\n## Basic idea\nThe parent process loops `n` times (for `n` commands) and creates `n-1` `Pipe`s. Therefore `n` child processes\nare created through `fork()`. Each child process has two variables in its address space:\n\n    let mut pipe_to_current: Option\u003cPipe\u003e;\n    let mut pipe_to_next: Option\u003cPipe\u003e;\n\nPipes communicates across process boundaries in the following way:\n\n    child process 0    child process 1    child process n\n    _______________    _______________    _________\n    | cat foo.txt |    | grep -i abc |    | wc -l |\n    ---------------    ---------------    ---------\n                ^        ^         ^        ^\n          WRITE |--------|  R / W  |--------| READ\n          END               E   E             END\n                       (current child)\n            -Pipe to Current-   -Pipe to Next-\n            \nEach process uses `pipe_to_current` (if present) as \"read end\" (as its `stdin`) and\n`pipe_to_current` (if present) as \"write end\" \n(duplicate it's `STDOUT` `file descriptor` into the write end of the pipe).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphip1611%2Funix_exec_piper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphip1611%2Funix_exec_piper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphip1611%2Funix_exec_piper/lists"}