frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

When 20 Watts Beats 20 Megawatts: Rethinking Computer Design

https://smarterarticles.co.uk/when-20-watts-beats-20-megawatts-rethinking-computer-design
1•dxs•3m ago•0 comments

Canadian Province New Brunswick to Quit Using Elon Musk's X

https://www.bloomberg.com/news/articles/2026-02-05/canadian-province-new-brunswick-to-quit-using-...
2•rbanffy•5m ago•0 comments

Heterogeneous Processing: A Strategy for Augmenting Moore's Law (2006)

https://www.linuxjournal.com/article/8368
1•rbanffy•6m ago•0 comments

Show HN: Mvvmm – Firecracker-like mini virtual machine monitor in ~2000 LoC

https://github.com/mistivia/mvvmm
1•mistivia•8m ago•0 comments

Search anything said on a podcast, speaker-labeled and speaker-tracked

https://poddley.com
1•onesandofgrain•8m ago•1 comments

Canada, better the 28th EU member than the 51st US state

https://www.lemonde.fr/en/opinion/article/2026/02/05/canada-better-the-28th-eu-member-than-the-51...
4•u1hcw9nx•9m ago•0 comments

Show HN: Team of agent researchers read things I don't have time to and brief me

https://read-fast.replit.app/
1•thomoliverz•11m ago•0 comments

Show HN: Chaos Agents – Run chaos experiments with Agents

https://github.com/system32-ai/chaos-agents
3•linuxarm64•12m ago•0 comments

Almostnode – Node.js in the Browser

https://github.com/macaly/almostnode
1•ushakov•12m ago•0 comments

Mount Fuji cherry blossom festival canceled due to overtourism

https://www.japantimes.co.jp/news/2026/02/05/japan/japan-mount-fuji-cherry-festival-overtourism/
3•akyuu•14m ago•0 comments

Containers, cloud, blockchain, AI – it's all the same old BS, says RH veteran

https://www.theregister.com/2026/02/08/waves_of_tech_bs/
1•lproven•15m ago•0 comments

Gorge (2022)

https://qntm.org/gorg
1•Rygian•16m ago•0 comments

Like Game-of-Life, but on Growing Graphs, with WASM and WebGL

https://znah.net/graphs/
1•znah•17m ago•0 comments

Show HN: agent-ledger – prevent double side effects when AI agents retry

https://github.com/rune0-dev/agent-ledger
1•itsimri•17m ago•0 comments

Gemini responds to request to turn on lights with hallucinated jailbreak prompt

https://www.reddit.com/r/googlehome/s/Lh3dYqccgB
4•visviva•19m ago•1 comments

RustCast -open-source Raycast-style launcher written in Rust

https://github.com/unsecretised/rustcast
1•todsacerdoti•19m ago•0 comments

Why Do Olympic Athletes Bite Their Medals?

https://www.thv11.com/article/sports/olympics/winter-games-iq/why-athletes-bite-medals-olympics/5...
1•RickJWagner•20m ago•0 comments

Mdash – Markdown in URL

https://kamilmac.github.io/mdash/
1•kmacinski•22m ago•0 comments

Brings your family memories now

https://familymemories.video
1•tareq_•22m ago•0 comments

Travel to Cheap Destinations

https://nomagicpill.substack.com/p/travel-to-cheap-destinations
1•surprisetalk•23m ago•0 comments

Rebuilding my home network with VLANs and 10Gbps

https://clintonboys.com/projects/homelab/03-network/
1•mtsolitary•24m ago•0 comments

Show HN: RepoSherlock – repo onboarding in minutes (map, run, risks)

1•kemal-arslan•25m ago•0 comments

Going Through Snowden Documents, Part 2

https://libroot.org/posts/going-through-snowden-documents-part-2/
2•stareatgoats•27m ago•0 comments

Can Europe get kids off social media?

https://www.ft.com/content/cf465c21-4789-490b-b328-41f6383567d7
2•thm•29m ago•0 comments

I Built a NAS (Buildlog)

https://arne.me/blog/buildlog-nas
2•abahlo•29m ago•0 comments

Making Software: How do computers store data?

https://www.makingsoftware.com/chapters/how-is-data-stored
3•Garbage•32m ago•0 comments

A timeline of claims about AI/LLMs

https://blog.nethuml.xyz/posts/2026/02/timeline-of-claims-about-ai-llms/
2•nethuml•34m ago•0 comments

Freeciv 3D with hex map tiles and WebGPU renderer

https://freecivworld.net/
2•roschdal•35m ago•0 comments

SpaceX-xAI Merger: Nobody's Talking About the von Neumann Elephant in the Room

1•juanpabloaj•39m ago•2 comments

Smart Homes Are Terrible

https://www.theatlantic.com/ideas/2026/02/smart-homes-technology/685867/
6•aarghh•43m ago•0 comments
Open in hackernews

Everything you never wanted to know about file locking (2010)

https://apenwarr.ca/log/20101213
91•SmartHypercube•1mo ago

Comments

Number-Six•1mo ago
So good in depth post. THANK YOU.
pseudohadamard•4w ago
Another good read is the SQLite locking module, https://www.sqlite.org/src/artifact/0240c5b547b4cf585c8cac35..., since these guys have to deal with the insanity of locking across different systems in real life.

You know things are bad when the least awful implementation of OS-level locking is the one from Microsoft.

ncruces•3w ago
POSIX locks are insane enough that when I reimplemented the SQLite file system API, I gave up on them: https://github.com/ncruces/go-sqlite3/tree/main/vfs#file-loc...
chasil•3w ago
One sure way to get a lock is to make a directory.

  #!/bin/sh

  if mkdir /your/lockdir
  then trap "rmdir /your/lockdir" EXIT INT ABRT TERM
       ...code goes here...
  else echo somebody else has the lock
  fi
No matter how many processes attempt to make the directory, only one will succeed. That works for my scripting, but I have never used it in C.
jofla_net•3w ago
this is great thanks,

was just wondering, could something else remove the dir in between the if and then, before trap?

Just wondering about the atomicity.

formerly_proven•3w ago
Yes, but that is not a weakness in the locking.
chasil•3w ago
The permissions on the parent and lock directory could restrict the access to a specific user and group, but yes, other processes could interfere with this locking if directed to do so.

One condition where this interference is helpful is a crash, where a @reboot entry in the crontab could:

  [ -d /your/lockdir ] && rmdir /your/lockdir
You would also not want to place the lock directory in /tmp or otherwise where other users could manipulate (or see) it. In Red Hat, there is a /var/run/lock directory that might be appropriate.

My biggest use case for directory locking in scripts is handling inotify events.

cryptonector•3w ago
The problem with lock files and lock directories is that if the lock holder dies without cleaning up you now need to do something to clean up.
mscdex•3w ago
On Linux, this is why I always turn to using abstract sockets when I only need local locking. Only one process can bind and the kernel cleans up automatically on process exit.

You could do the same thing with TCP/UDP, but abstract sockets give you more flexibility in naming with 108 characters vs. being forced to use a 16-bit integer. Also it means you aren't using up a port that could otherwise be used for actual network communication.

Abstract sockets also make for a nice process existence monitoring mechanism since any processes connected to the bound socket are guaranteed to be immediately notified when the process dies.

acuozzo•3w ago
Is this guaranteed to be atomic on all filesystems?
chasil•3w ago
For POSIX, yes.

https://rcrowley.org/2010/01/06/things-unix-can-do-atomicall...

Windows has a deep well of POSIX in the kernel (plus hard file locks), and it appears to hold there.

https://en.wikipedia.org/wiki/Microsoft_POSIX_subsystem

elteto•3w ago
It’s even atomic on NFS. In fact, it’s probably the only reliable locking mechanism on NFS.
Bratmon•3w ago
Usually when I read these writeups, I walk away thinking "Wow, $foo was a more complicated problem than I thought".

With this one, it was "Wow, $foo was a simpler problem than I thought and Unix (and thus Linux and OSX) just totally screwed it up for no reason"

jabl•3w ago
As TFA mentions, Unix/POSIX locking is insane.

Note that this page is slightly outdated wrt. flock(). From the manpage (online at https://man7.org/linux/man-pages/man2/flock.2.html):

>

       Since Linux 2.0, flock() is implemented as a system call in its
       own right rather than being emulated in the GNU C library as a
       call to fcntl(2).  With this implementation, there is no
       interaction between the types of lock placed by flock() and
       fcntl(2), and flock() does not detect deadlock.  (Note, however,
       that on some systems, such as the modern BSDs, flock() and
       fcntl(2) locks do interact with one another.)

   CIFS details
       Up to Linux 5.4, flock() is not propagated over SMB.  A file with
       such locks will not appear locked for remote clients.

       Since Linux 5.5, flock() locks are emulated with SMB byte-range
       locks on the entire file.  Similarly to NFS, this means that
       fcntl(2) and flock() locks interact with one another.  Another
       important side-effect is that the locks are not advisory anymore:
       any IO on a locked file will always fail with EACCES when done
       from a separate file descriptor.  This difference originates from
       the design of locks in the SMB protocol, which provides mandatory
       locking semantics.

       Remote and mandatory locking semantics may vary with SMB protocol,
       mount options and server type.  See mount.cifs(8) for additional
       information.

   NFS details
       Up to Linux 2.6.11, flock() does not lock files over NFS (i.e.,
       the scope of locks was limited to the local system).  Instead, one
       could use fcntl(2) byte-range locking, which does work over NFS,
       given a sufficiently recent version of Linux and a server which
       supports locking.

       Since Linux 2.6.12, NFS clients support flock() locks by emulating
       them as fcntl(2) byte-range locks on the entire file.  This means
       that fcntl(2) and flock() locks do interact with one another over
       NFS.  It also means that in order to place an exclusive lock, the
       file must be opened for writing.

       Since Linux 2.6.37, the kernel supports a compatibility mode that
       allows flock() locks (and also fcntl(2) byte region locks) to be
       treated as local; see the discussion of the local_lock option in
       nfs(5).
IshKebab•3w ago
Hmm I just ran into an issue with uv where it deadlocks because of something to do with file locking on NFS. This looks informative!
krautburglar•3w ago
It would be nice to have a unix for the new millenium--one that discards everything the greybeards deem a mistake. The window of opportunity is closing. We won't have them much longer.
squirrellous•3w ago
This is my go to article every time I think about using file locking to solve a problem.

Also, OFD locks are great if you target Linux only these days.