The READIN Family Album
Sylvia's on the back (October 2005)

READIN

Jeremy's journal

A memorandum-book does not, provided it is neatly written, appear confused to an illiterate person, or to the owner who understands it thoroughly, but to any other person able to read it appears to be inextricably confused.

James Clerk Maxwell


(This is a page from my archives)
Front page
More recent posts
Older posts
More posts about:
Programming
Programming Projects
Projects

Archives index
Subscribe to RSS

This page renders best in Firefox (or Safari, or Chrome)

🦋 errno

Perhaps you are a programmer; perhaps you use gdb to step through the programs you have written, looking for bugs; perhaps you have wondered why gdb will not let you examine the contents of the errno variable. Here's the deal: if you are typing print errno and getting the message Cannot access memory at address 0x8, it is because errno is not an actual variable; the compiler has replaced references to errno with *__errno_location() --

print *__errno_location()
will give you what you're looking for.

posted morning of Thursday, August 20th, 2009
➳ More posts about Programming
➳ More posts about Programming Projects
➳ More posts about Projects

This is one of the changes to *nix made to accomodate multi-threading; there is now one errno per thread.

Personally, I favor rfork() over the POSIX threading model, which is an incredibly fruitful source of bugs.

posted morning of August 20th, 2009 by Randolph

I don't know about rfork -- I should find out about it. I did not realize errno was allocated by thread, makes sense -- so that's why I don't have to enclose api calls and errno checks in mutex.

posted morning of August 20th, 2009 by Jeremy

How is rfork different from fork()? I like threads because of the shared memory between the parent and the child, though obviously this is bug-prone. You're arguing against multithreaded processes in general?

posted morning of August 20th, 2009 by Jeremy

Looks like I'm safe (for some values of "safe")... rfork() system call does not appear to be implemented on my OS. (Linux v. 2.6.9-42.ELsmp/RedHat 3.4.6-2)

posted morning of August 20th, 2009 by Jeremy

rfork.

There's uses for threads, sure, but I wish they hadn't become an everyday tool--they make simple things very difficult. By and large I find the fork() model of process management hugely safer and more predictable than threading. Threading, as a retrofit, also messes up the Unix system call API (including errno, which started this thread), which was never designed to be reentrant.

posted morning of August 22nd, 2009 by Randolph

Respond:

Name:
E-mail:
(will not be displayed)
Link:
Remember info

Drop me a line! or, sign my Guestbook.
    •
Check out Ellen's writing at Patch.com.

Where to go from here...

Friends and Family
Programming
Texts
Music
Woodworking
Comix
Blogs
South Orange
readinsinglepost