Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> The syscall/errno stuff has always seemed unusual, inelegant, and inefficient

And non-reentrant.

errno is usually defined as TLS (thread local storage).

It's a mess.



Yes, if UNIX had supported multithreading from the start, there is no way they would have chosen "errno" as the solution.

Obvious in hindsight, not so much in the 1970s.


Can you elaborate on how "errno"'s design is rooted in the fact that there was no multithreading at the time? I am not understanding the connection. Thanks.


Multithreading usually means that threads share the address space and so can (inadvertently) stomp on each other's "errno". (Hence making it Thread-Local Storage to solve that issue. Doesn't solve the reentrancy issue, though.)

If multithreading were pervasive nobody in their right mind would choose to use a global variable for error status codes.


Ah yes that makes sense. Thanks!


Somehow VMS managed to avoid that same mistake in the 70s.


I keep hearing that a lot!

VMS sounds amazing, but somehow I'm still thinking this might be nostalgia.


Is TLS actually needed for anything else than errno/GetLastError/SDL_GetError/etc. ?


Thread id :)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: