frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

psc: The ps utility, with an eBPF twist and container context

https://github.com/loresuso/psc
107•tanelpoder•3w ago

Comments

apopapo•3w ago
> psc uses eBPF iterators to read process and file descriptor information directly from kernel data structures. This bypasses the /proc filesystem entirely, providing visibility that cannot be subverted by userland rootkits or LD_PRELOAD tricks.

Is there a trade off here?

tempay•3w ago
It requires root
mgaunard•3w ago
Running eBPF programs doesn't strictly require root.
cpuguy83•3w ago
It requires cap_bpf which is considered a high privileged capability.

So yes, it requires root in the sense of what people mean by root.

mgaunard•3w ago
You can also enable unpriviledged ebpf.
mgaunard•3w ago
I found this justification dubious. To me the main reason to use eBPF is that it gives more information and is lower overhead.
mrbluecoat•3w ago
Thanks for including so many examples! Perhaps include one example output. Other than mention of the optional '--tree' parameter, it's unclear if the default result would be a list, table, JSON, etc.
WD-42•3w ago
This is neat but the examples comparing the tool against piping grep seem to counter the argument to me. A couple of pipes to grep seems much easier to remember and type, especially with all the quotes needed for psc. For scripts where you need exact output this looks great.
pstoll•3w ago
I’m the opposite - I much prefer a structured query language (ahem) for this type of thing. If I’m looking at someone’s (ie my own 6 months later) script I much prefer to see the explicit structure being queried vs “why are we feeling for foo or grabbing the 5th field based on squashed spaces as the separater”.

Nice use of CEL too. Neat all around.

mgaunard•3w ago
I'm not convinced with the need to embed CEL. You could just output json and pipe to jq.
guerrilla•3w ago
Sounds less efficient in both space and time.
pstuart•3w ago
I guess it's a matter of muscle memory and workflow. It's nice to have options.
guerrilla•2w ago
Fair enough. Letting the computer do the work instead of the brain/body.
foobarqux•3w ago
Their first example is bad:

    ps aux | grep nginx | grep root | grep -v grep
can be done instead (from memory, not at a Linux machine ATM):

    ps -u root -C nginx
which is arguably better than their solution:

    psc 'process.name == "nginx" && process.user == "root"'
xorcist•3w ago
The commands in their example are not equivalent. The ps | grep thing searches the full command line including argument while ps -C (and, presumably, the psc thing) just returns the process name.

Should you for some reason want to do the former, this is easiest done using:

  pgrep -u root -f nginx
which exists on almost all platforms, with the notable exception of AIX.

Their other slightly convoluted example is:

  psc 'socket.state == established && socket.dstPort == uint(443)'
which is much more succinct with:

  lsof -i :443 -s TCP:ESTABLISHED
wang_li•3w ago
Many new tools appear because people don't know how to use the existing tools or they think the existing tool is too complicated. In time the new tool becomes just as, or more, complicated than the old tool. Because there is a reason the old tool is complicated, which is that the problem requires complexity.
dundarious•3w ago
It has process.cmdline as well as .name
mxey•3w ago
“ss” also has filters, no need for grep

ss -o state established '( dport = :ssh or sport = :ssh )'

fellowmartian•3w ago
An unfortunate name that triggers everybody who’s ever worked at Meta :)
yjftsjthsd-h•3w ago

  # Find processes connected to a specific port
  psc 'socket.dstPort == uint(443)'

  # Filter by PID range
  psc 'process.pid > 1000 && process.pid < 2000'

It seems weird to require the user to remember that ports have to be marked uint when it doesn't look like anything else does.
ralferoo•3w ago
PIDs haven't been limited to 16-bits for a long time. I guess the default integer in these things is 32-bit signed.

But, yeah, this could be solved if uint promoted to larger for the comparison.

grantseltzer•3w ago
I've played with bpf iterators and wrote a post about them [1]. The benefit of iterating over tasks instead of scanning procfs is a pretty astounding performance difference:

> I ran benchmarks on current code in the datadog-agent which reads the relevant data from procfs as described at the beginning of this post. I then implemented benchmarks for capturing the same data with bpf. The performance results were a major improvement.

> On a linux system with around 250 Procs it took the procfs implemention 5.45 ms vs 75.6 us for bpf (bpf is ~72x faster). On a linux system with around 10,000 Procs it took the procfs implemention ~296us vs 3ms for bpf (bpf is ~100x faster).

[1] https://www.grant.pizza/blog/bpf-iter/

stefan_•3w ago
procfs and "everything is a file" is up there with fork on the "terrible useless technology that is undeservedly revered".
tanelpoder•3w ago
And with eBPF iterators you can bail out early and move to next if you see a non-interesting item (or one that should be filtered out) instead of emitting textual data of all items and later grepping/filtering things out in post-processing.

I use early bailout a lot (in 0x.tools xcapture) when iterating through all threads in a system and determining which ones are “active” or interesting

rfl890•3w ago
It took less time for 10,000 processes? Maybe you made a typo
zokier•3w ago
how about comparing it to something sensible like osquery instead of doing silly strawman ps pipelines
dundarious•3w ago
I like this tool. I just replaced a multi-step script to find running processes with deleted files open (e.g., updated shared library or binary) that used to be as follows:

- grep /proc/*/maps for " (deleted)" (needs root)

- exclude irrelevancies like paths starting with "/memfd:" (I have lots of other similar exclusions) with grep -v

- extract the pid from the filename part of grep's output with sed

- for each pid, generate readable output from /proc/$pid/cmdline (which is NUL separated) with tr, xargs, bash printf

- show the pid, cmdline, file path

Yes, this is what needs-restarting does too.

With this tool, this pipe chain is now just:

    doas psc -o "process.pid,process.cmdline,file.path" \
      'file.path.endsWith(" (deleted)") && !file.path.startsWith("/memfd:") && !...' \
      | sed 1d
loresuso•3w ago
Hey! thanks for publishing my tool, and thanks everybody for the great feedback here. Just started addressing some of your points.

Anyway, my need for the tool was mostly because of these few points:

- scripting can be much easier with psc, especially when you can output what you want

- ebpf iterators are so flexible: we can get anything that is defined in the task_struct that is not even exposed in the proc filesytem if we want. This alone makes the tool extremely powerful, with a reasonable amount of effort for just adding a new field

- I really like querying my system with a simple language. Sometimes I tend to forget about specific ss, lsof, or ps options. In this way, it's much easier for me to get what I need

- no traditional tooling has native container context. It can be extended to even retrieve data from the kubelet, for instance, but I'll think about it

Feel free to reach out if you have any particular need

dvfjsdhgfv•2w ago
Excellent work, thank you!

OpenCiv3: Open-source, cross-platform reimagining of Civilization III

https://openciv3.org/
539•klaussilveira•9h ago•150 comments

The Waymo World Model

https://waymo.com/blog/2026/02/the-waymo-world-model-a-new-frontier-for-autonomous-driving-simula...
866•xnx•15h ago•525 comments

How we made geo joins 400× faster with H3 indexes

https://floedb.ai/blog/how-we-made-geo-joins-400-faster-with-h3-indexes
73•matheusalmeida•1d ago•15 comments

Show HN: Look Ma, No Linux: Shell, App Installer, Vi, Cc on ESP32-S3 / BreezyBox

https://github.com/valdanylchuk/breezydemo
185•isitcontent•10h ago•21 comments

Monty: A minimal, secure Python interpreter written in Rust for use by AI

https://github.com/pydantic/monty
186•dmpetrov•10h ago•82 comments

Show HN: I spent 4 years building a UI design tool with only the features I use

https://vecti.com
296•vecti•12h ago•132 comments

Dark Alley Mathematics

https://blog.szczepan.org/blog/three-points/
72•quibono•4d ago•15 comments

Microsoft open-sources LiteBox, a security-focused library OS

https://github.com/microsoft/litebox
346•aktau•16h ago•168 comments

Sheldon Brown's Bicycle Technical Info

https://www.sheldonbrown.com/
341•ostacke•15h ago•90 comments

Hackers (1995) Animated Experience

https://hackers-1995.vercel.app/
437•todsacerdoti•17h ago•226 comments

Unseen Footage of Atari Battlezone Arcade Cabinet Production

https://arcadeblogger.com/2026/02/02/unseen-footage-of-atari-battlezone-cabinet-production/
8•videotopia•3d ago•0 comments

Show HN: If you lose your memory, how to regain access to your computer?

https://eljojo.github.io/rememory/
240•eljojo•12h ago•147 comments

What Is Ruliology?

https://writings.stephenwolfram.com/2026/01/what-is-ruliology/
4•helloplanets•4d ago•0 comments

Delimited Continuations vs. Lwt for Threads

https://mirageos.org/blog/delimcc-vs-lwt
15•romes•4d ago•2 comments

PC Floppy Copy Protection: Vault Prolok

https://martypc.blogspot.com/2024/09/pc-floppy-copy-protection-vault-prolok.html
43•kmm•4d ago•3 comments

An Update on Heroku

https://www.heroku.com/blog/an-update-on-heroku/
378•lstoll•16h ago•253 comments

How to effectively write quality code with AI

https://heidenstedt.org/posts/2026/how-to-effectively-write-quality-code-with-ai/
222•i5heu•12h ago•166 comments

Show HN: ARM64 Android Dev Kit

https://github.com/denuoweb/ARM64-ADK
14•denuoweb•1d ago•2 comments

Why I Joined OpenAI

https://www.brendangregg.com/blog/2026-02-07/why-i-joined-openai.html
94•SerCe•5h ago•77 comments

Show HN: R3forth, a ColorForth-inspired language with a tiny VM

https://github.com/phreda4/r3
62•phreda4•9h ago•11 comments

Learning from context is harder than we thought

https://hy.tencent.com/research/100025?langVersion=en
162•limoce•3d ago•82 comments

I spent 5 years in DevOps – Solutions engineering gave me what I was missing

https://infisical.com/blog/devops-to-solutions-engineering
128•vmatsiiako•14h ago•55 comments

Introducing the Developer Knowledge API and MCP Server

https://developers.googleblog.com/introducing-the-developer-knowledge-api-and-mcp-server/
38•gfortaine•7h ago•11 comments

Zlob.h 100% POSIX and glibc compatible globbing lib that is faste and better

https://github.com/dmtrKovalenko/zlob
6•neogoose•2h ago•2 comments

Understanding Neural Network, Visually

https://visualrambling.space/neural-network/
261•surprisetalk•3d ago•35 comments

Female Asian Elephant Calf Born at the Smithsonian National Zoo

https://www.si.edu/newsdesk/releases/female-asian-elephant-calf-born-smithsonians-national-zoo-an...
18•gmays•5h ago•2 comments

I now assume that all ads on Apple news are scams

https://kirkville.com/i-now-assume-that-all-ads-on-apple-news-are-scams/
1030•cdrnsf•19h ago•428 comments

FORTH? Really!?

https://rescrv.net/w/2026/02/06/associative
55•rescrv•17h ago•19 comments

Show HN: Smooth CLI – Token-efficient browser for AI agents

https://docs.smooth.sh/cli/overview
84•antves•1d ago•60 comments

WebView performance significantly slower than PWA

https://issues.chromium.org/issues/40817676
19•denysonique•6h ago•3 comments