{"id":20395268,"url":"https://github.com/philippkeller/apue-rust","last_synced_at":"2025-07-15T10:08:30.123Z","repository":{"id":63112716,"uuid":"62703229","full_name":"philippkeller/apue-rust","owner":"philippkeller","description":"Examples and Exercises in Rust from \"Advanced Programming in the UNIX Environment\"","archived":false,"fork":false,"pushed_at":"2017-05-02T05:17:25.000Z","size":306,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T12:24:48.003Z","etag":null,"topics":["educational","rust","unix-environment"],"latest_commit_sha":null,"homepage":"https://backl.io","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/philippkeller.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":"2016-07-06T08:09:07.000Z","updated_at":"2024-11-24T07:41:26.000Z","dependencies_parsed_at":"2022-11-13T03:45:35.007Z","dependency_job_id":null,"html_url":"https://github.com/philippkeller/apue-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/philippkeller/apue-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippkeller%2Fapue-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippkeller%2Fapue-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippkeller%2Fapue-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippkeller%2Fapue-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philippkeller","download_url":"https://codeload.github.com/philippkeller/apue-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippkeller%2Fapue-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265427458,"owners_count":23763321,"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":["educational","rust","unix-environment"],"created_at":"2024-11-15T03:55:53.221Z","updated_at":"2025-07-15T10:08:30.086Z","avatar_url":"https://github.com/philippkeller.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"I'm reading through \"[Advanced Programming in the UNIX Environment](https://www.amazon.com/dp/0321637739)\". My dislike of C caused me to learn Rust and port some of the examples and exercises from C to Rust.\n\nBeware: this is my first Rust project. This code is far from beautiful and might have mistakes (e.g. dangling pointers). PR are *very* welcome. All code is tested on OS X and most on it also on Linux.\n\n## Progress\n\n- [x] Chapter 1: Overview\n- [x] Chapter 2: UNIX Standardization and Implementations\n- [x] Chapter 3: File I/O\n- [x] Chapter 4: Files and Directories\n- [x] Chapter 5: Standard I/O Library\n- [x] Chapter 6: System Data Files and Information\n- [x] Chapter 7: Process Environment\n- [x] Chapter 8: Process Control\n- [x] Chapter 9: Process Relationships\n- [x] Chapter 10: Signals\n- [x] Chapter 11: Threads\n- [ ] Chapter 12: Thread control\n\n## Using this code\n\nTODO: \n\n- can you copy-paste this code for your project? Mostly, yes, but some examples are probably optimal because\nthey copy data (e.g. buffers) even when unneeded.\n- explain some basic usage `cstr!`, `to_option()` and working with buffers allocated via vectors.\n\n## Building\n\n- Building should work out of the box for Macos and Linux on rust nightly.\n- Some of the binaries only do something on Macos, others only for Linux (see #cfg switches in the main methods)\n- If you regularly switch between building MacOs and Linux you can tell cargo to put those files in different directories\n  using `export CARGO_TARGET_DIR=target/linux`\n  \n## Code not ported to Rust:\n\n- Figure 7.9, 7.11, 7.13: setjmp, longjmp: of course Rust solves this with exception handling (i.e. with explicit \n  error handling or using `panic::catch_unwind`). These sections (as well as the one about malloc, etc.) are\n  actually very good reasons why to not use C directly but instead turn to something safer like Rust.\n  In addition to that: Rust doesn't offer a way to safe unwind the stack after a longjump: \n  https://users.rust-lang.org/t/force-cleanup-before-longjmp/3376\n- Figure 7.14: That's exactly why you take Rust over C because Rust will complain at compile time that you cannot\n  return a stack variable from a function.\n- Figure 8.13: avoid race condition: the synchronization features in Rust don't allow syncing of forks (only available\n  for threads, see e.g. https://github.com/BurntSushi/chan-signal/issues/13), so I skipped this Figure, maybe\n  coming back to this later (when signals are discussed in later chapters)\n- Figure 10.8, 10.9, 10.11, 10.20: rust does not have setjmp/longjmp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilippkeller%2Fapue-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilippkeller%2Fapue-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilippkeller%2Fapue-rust/lists"}