{"id":16752684,"url":"https://github.com/luser/spawn-task-port","last_synced_at":"2025-04-10T15:52:35.461Z","repository":{"id":57668076,"uuid":"83695665","full_name":"luser/spawn-task-port","owner":"luser","description":"A Rust crate to spawn a child process on OS X and get the child's Mach task port","archived":false,"fork":false,"pushed_at":"2023-04-22T22:40:42.000Z","size":10,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T13:43:38.428Z","etag":null,"topics":[],"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/luser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-02T15:52:17.000Z","updated_at":"2025-01-21T22:10:51.000Z","dependencies_parsed_at":"2025-02-17T13:37:08.212Z","dependency_job_id":"5c03f8fa-0872-42fd-92d6-79804d3bcd0b","html_url":"https://github.com/luser/spawn-task-port","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luser%2Fspawn-task-port","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luser%2Fspawn-task-port/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luser%2Fspawn-task-port/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luser%2Fspawn-task-port/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luser","download_url":"https://codeload.github.com/luser/spawn-task-port/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248245473,"owners_count":21071495,"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":[],"created_at":"2024-10-13T02:47:48.319Z","updated_at":"2025-04-10T15:52:35.437Z","avatar_url":"https://github.com/luser.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/luser/rust-spawn-task-port.svg?branch=master)](https://travis-ci.org/luser/rust-spawn-task-port) [![crates.io](https://img.shields.io/crates/v/spawn-task-port.svg)](https://crates.io/crates/spawn-task-port) [![](https://docs.rs/spawn-task-port/badge.svg)](https://docs.rs/spawn-task-port)\n\nA crate to spawn a child process on OS X and get the child's Mach task port. [Many useful OS X kernel APIs](http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/) require access to the task port, and in recent releases of OS X the security around `task_for_pid` has been tightened such that it no longer works reliably even as root. However, for processes that you are spawning it is possible to have the child cooperate and send its task port to the parent. This crate uses `CommandExt::before_exec` and a handful of Mach APIs to have the child process do just that.\n\nMuch of this code is written using information from Michael Weber's [Some Fun with Mach Ports](http://web.archive.org/web/20160703203506/https://www.foldr.org/~michaelw/log/computers/macosx/task-info-fun-with-mach) blog post, and other bits were gleaned from [Chromium's mach_port_broker.mm](https://chromium.googlesource.com/chromium/src.git/+/466f0cb8d47e7da69a06cb6dc9b60fe5511fc8d1/base/mac/mach_port_broker.mm).\n\nThis crate was written so I could use it to write tests for the [read-process-memory](https://github.com/luser/read-process-memory) crate. You may find this crate useful in conjunction with that one!\n\n\n# Example\n\n```rust,no_run\nextern crate spawn_task_port;\n\nuse std::ffi::OsString;\nuse std::io;\nuse std::process::Command;\nuse spawn_task_port::CommandSpawnWithTask;\n\n// Spawn `exe` with `args` as a child process and do interesting\n// things to it.\nfn do_some_work(exe: OsString, args: Vec\u003cOsString\u003e) -\u003e io::Result\u003c()\u003e {\n let (mut child, task_port) = Command::new(\u0026exe)\n        .args(\u0026args)\n        .spawn_get_task_port()?;\n // Now you can call mach APIs that require a `mach_port_t` using `task_port`,\n // like `vm_read`.\n child.wait()?;\n Ok(())\n}\n\nfn main() {\n   use std::env;\n   let mut args = env::args_os().skip(1);\n   let exe = args.next().unwrap();\n   let rest: Vec\u003c_\u003e = args.collect();\n   do_some_work(exe, rest).unwrap();\n}\n```\n\n# Documentation\n\n[https://docs.rs/spawn-task-port](https://docs.rs/spawn-task-port)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluser%2Fspawn-task-port","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluser%2Fspawn-task-port","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluser%2Fspawn-task-port/lists"}