Log in

No account? Create an account

November 28th, 2007

Computer Truthiness

This is the most awesomest command eva!

% true

eh? ... omg did it really really ...

% true --help
Usage: true [ignored command line arguments]

HAH!!  Somehow the sheer simplicity, aka. uber-minimalism, of someone building this into bash and csh made my day.  My nephews didn't get it ... *shrug*  It's silly, I know, but still.  OK, so I'm easily amused.  :)

I somehow bumped into the command while trying to find out how some hackers defaced two of our websites.  Okay, so it's not entirely work related; I was tracing how the Linux kernel handles executables.  This kind of stuff -- operating system internals -- has always intrigued me and one of the reasons why I was delighted to see Sysinternals mentioned in the book I was reviewing.  It'd be grande to get Linus Torvalds, David Cutler, and someone like Steve Wozniak at a round table talking about kernels.  Grand in my mind anyways.  Hehe.  Anyways, tracing what the system is doing, aka. strace, turns out to be rather intuitive; although verbose for a command that always returns success, this was interesting:

% strace true
  • execve()
    • execute "true"
  • mmap2()
    • map file "true" into memory (4K blocks)
  • open()
    • open a standard library (for processing the mapped memory)
  • read()
    • read the library (512bytes at a time)
  •  ... several mmaps later ...
  • munmap()
    • free the memory
  • close()
    • close the library
  • exit_group()
    • done!
That's a list that reduces what actually happened to a more reader-friendly version that makes sense.  The actual work happened inbetween the ellipses when memory was moved around.  There's also several functions that I skipped that deal with language, aka. localization, so that the (non-existent) result could be seen by users -- or formatted so it can be teletyped for braille users, or sent in a format that can be synthesized into audio for the blind, etc.  This trace fell right into my second love: accessibility.  Godz I should have taken more computer courses!