Hacker News new | past | comments | ask | show | jobs | submit login

it's actually much easier than that: https://github.com/kahing/bin/blob/master/cleancache.c



True, but there are a few gotchas with that version. It won't work with execve, it doesn't cache the binary, it won't work if called with "source", it doesn't set argv[0] properly when the binary is called, and a few other things. It is nice and terse though.


execve and binary caching are relatively easy to implement, as is argv[0]. Do people actually care about making "source" work?


execve compatibility is not easy at all, since it requires a shebang line which isn't valid C. However thanks to emmelaich's // idea I just figured out a way to do it using fewer lines than your #if 0 solution.

https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83...


I can't decide if that's cute, or eye-bleedingly criminal.

Neat though, and I haven't seen it before.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: