addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Just resting my eyes: the `sleep` program

This meetup concentrates on the common and simple commands; this time: sleep.

The sleep command pauses for the given number of seconds, then exits sucessfully. Think of it as a little break for your computer. You can read its exact specification as declared by POSIX.

We will look at OpenBSD, FreeBSD, NetBSD, and GNU command-line implementations, plus the mksh and AT&T ksh sleep built-ins.

With the many different authors and distinct cultures we will be sure to have much to discuss and compare. Some things to think about: what are some uses for the sleep command? How do the different implementations pause the program, and why would they choose select vs nanosleep vs xnanosleep? How are signals important to the program? Which ones handle units smaller than a second, and how is this useful? This program as defined by POSIX does no I/O; how do the various programs introduce I/O, and why? Do all of these programs allow one to sleep forever?

Just in case you don't have six copies of sleep.c sitting on your hard drive, you can find them online:





MirBSD Korn shell:

AT&T Korn shell:

This should all take about three hours. Food and drinks will be provided by thoughtbot.

About us:

This is a reading group for code. Our focus is the classics and tools we use every day. The inspiration is the shared metaphors and expressions we have in natural language due to common books (e.g.  Hitchhiker's Guide to the Galaxy, Romeo and Juliet) and movies (e.g.  Hackers, A Christmas Carol).

Join or login to comment.

  • Hans A.

    I suggest a placeholder upcoming event be created immediately after each event. As a medium for debating the program/subject/agenda and possibly date and/or venue.

    May 25, 2014

    • Mike B.

      The venue is The Park, and I'll pick the programs. But I do like the suggestions being discussed here!

      May 26, 2014

    • Hans A.

      So... Change that to ...for suggestions

      May 26, 2014

  • Bengt B.

    Another lesser known utility that is short is the /usr/bin/tee. It clocks in at about 135 lines (or was that 150 lines?)

    May 24, 2014

    • Hans A.

      Tee illustrates a basic idea in unix, the pipe, taken one step further. I think tee appeared in BSD first, but I could be wrong.

      May 25, 2014

  • Bengt B.

    I love these readings.

    May 24, 2014

  • Hans A.

    Suggestion for next meetup: /bin/ln. Not too large and lots will be repeats from earlier sessions. There's about 150 lines to look at, and they will show hw optimization and file system related but not too specific stuff.

    May 24, 2014

    • Hans A.

      The earliest BSD ln is less than 80 lines. Interesting to see how ln evolves during the first few years.

      May 24, 2014

  • Zeke V.

    The Korn code was a real eye opener :-)

    May 22, 2014

  • Giovanni S.

    And that's me having to miss it. I'll be busy again :(

    May 21, 2014

  • Mikael M.

    I realized that I was already booked up for this evening, so unfortunately I can't come by :-(.

    May 20, 2014

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy