{"id":16476628,"url":"https://github.com/siadat/ptail","last_synced_at":"2026-04-30T00:02:10.119Z","repository":{"id":228901532,"uuid":"775224303","full_name":"siadat/ptail","owner":"siadat","description":"view stdout/stderr of a process","archived":false,"fork":false,"pushed_at":"2024-04-10T16:10:53.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T21:39:59.713Z","etag":null,"topics":["cat","linux","ptrace","strace","zig"],"latest_commit_sha":null,"homepage":"https://siadat.github.io/blog/post/ptrace","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siadat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-03-21T01:33:19.000Z","updated_at":"2024-12-23T09:07:35.000Z","dependencies_parsed_at":"2024-04-09T11:39:06.183Z","dependency_job_id":null,"html_url":"https://github.com/siadat/ptail","commit_stats":null,"previous_names":["siadat/pcat","siadat/ptail"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siadat%2Fptail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siadat%2Fptail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siadat%2Fptail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siadat%2Fptail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siadat","download_url":"https://codeload.github.com/siadat/ptail/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247218645,"owners_count":20903277,"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":["cat","linux","ptrace","strace","zig"],"created_at":"2024-10-11T12:43:07.311Z","updated_at":"2026-04-30T00:02:05.065Z","avatar_url":"https://github.com/siadat.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ptail\n\nptail (process tail) is a simple tool for viewing the stdout and stderr of a process.\nThink of it as tail -f for the output of other processes.\n\n## Usage\n\nThere are two ways to use ptail (similar to strace): ptail a new process (with a given program), or ptail an exiting process (with PID).\n\n```bash\n# new process\n./zig-out/bin/ptail PROGRAM [ARGS...]\n```\n\n```bash\n# exiting process\nsudo ./zig-out/bin/ptail -p PID\n```\n\n## When would it be useful?\n\n1. There are situations in which the stdout and stderr of a process are captured and not shown. For example, `zig build test` with [.test_server_mode](https://sourcegraph.com/github.com/ziglang/zig@b88ae8dbd84886d3b9b26509034720f755a0e28a/-/blob/lib/std/Build/Step/Compile.zig?L59:1-59:17) captures stdout and stderr of processes and does not show them until the end of tests.\nIf a test is blocked, nothing is shown and you cannot do printf debugging. You can use the following command to see the output of the tests as they are running:\n```\n./zig-out/bin/ptail /usr/bin/bash -c 'zig build test'\n```\n\n2. The process is running in the background and its stdout is either not written to disk, or you don't know where it is. For example, you can inspect what your language server (eg zls) is printing with the following command:\n```\nsudo ./zig-out/bin/ptail -p $(ps -C \"zls\" -o pid= | head -1)\n```\n\n## Example\n\n### Monitor new process\n\n```bash\n./zig-out/bin/ptail /usr/bin/bash -c 'ping localhost \u003e /dev/null'\n```\n\n### Monitor existing process\n\n```bash\n# terminal 1\nping localhost \u003e /dev/null\n```\n\n```bash\n# terminal 2\nsudo ./zig-out/bin/ptail -p $(ps -C \"ping\" -o pid= | head -1)\n64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.058 ms\n64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.067 ms\n...\n```\n\n### Asciinema\n\n[![asciicast](https://asciinema.org/a/AnISVmtu2NVEs8ssFqQ8XVYEo.svg)](https://asciinema.org/a/AnISVmtu2NVEs8ssFqQ8XVYEo)\n\n## Build\n\n```\nzig build\n```\n\n* Requires Linux kernel 5.3 or later, but let me know if you need support for older kernels. We just need to bring back the code removed in [commit/ceedab19](https://github.com/siadat/ptail/commit/ceedab194d6beddb7f01d3f6039261c3ec88db77?diff=split\u0026w=1) for systems where PTRACE_SYSCALL_INFO_EXIT is not available.\n* Tested with Zig version 0.12.0-dev.3496+a2df84d0f\n\n## Test\n\n```\nzig build test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiadat%2Fptail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiadat%2Fptail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiadat%2Fptail/lists"}