sleep(3)

๐Ÿ’ค sleep(3) โ€” the "bestie go take a nap" function

okay so this is sleep(3), and yeah it lives in the Library Functions Manual section 3, which is where all the library-call girlies hang out. it's a function, not a command, so no shell prompt energy here โ€” you're calling this from C, bestie. ๐Ÿ’…


๐ŸŒธ NAME

sleep โ€” sleep for a specified number of seconds

like. literally just nap for a bit. that's the whole job. iconic behavior honestly.

๐Ÿ“š LIBRARY

Standard C library (libc, -lc)

so yeah, link it with -lc like every other basic libc function. nothing exotic. ๐ŸŽ€

โœจ SYNOPSIS

#include <unistd.h>

unsigned int sleep(unsigned int seconds);

one include, one call, one lil unsigned int in and one unsigned int out. we love a minimal API. ๐Ÿฆ‹

๐Ÿซถ DESCRIPTION

okay so sleep() makes the calling thread go night-night ๐Ÿ›Œ โ€” it sleeps either until the number of real-time seconds you passed in have actually elapsed, or until a signal shows up that isn't being ignored.

that's it. that's the tea. also heads up โ€” it's the calling thread that snoozes, not the whole process, so your other thread besties keep vibing. ๐Ÿ’–

๐ŸŽ€ RETURN VALUE

  • 0 โ€” the requested time fully elapsed, you got your full nap, slay ๐Ÿ˜Œ
  • the number of seconds left to sleep โ€” the call got interrupted by a signal handler, so it hands you back the leftover time like "here's what you still owe the sandman" โณ

๐Ÿ’€ ATTRIBUTES

for the explanation of the terms used in this section, go peek at attributes(7). it's giving required reading, ngl.

  • Interface: sleep()
  • Attribute: Thread safety
  • Value: MT-Unsafe sig:SIGCHLD/linux

no cap, that MT-Unsafe with the sig:SIGCHLD/linux tag is the part you screenshot and remember. ๐Ÿ˜ญ

๐ŸŒˆ VERSIONS

on Linux, sleep() is implemented via nanosleep(2). so if you wanna know about the clock it's using, the nanosleep(2) man page has the whole discussion โ€” go read it, i'll wait ๐Ÿซถ

on some systems, sleep() might be implemented with alarm(2) and SIGALRM instead โ€” and yeah, POSIX.1 permits that lil switcheroo. which means mixing calls to alarm(2) and sleep() is a bad idea. like, genuinely bad. don't do it. ๐Ÿ’€

โญ STANDARDS

POSIX.1-2008. certified, official, legitimate. ๐Ÿ‘‘

๐Ÿฆ‹ HISTORY

POSIX.1-2001. so it's been around, it's a legacy queen, it's been doing this since forever. ๐Ÿ’œ

๐Ÿ˜ญ CAVEATS

listen. this is the scary part. danger energy only:

using longjmp(3) from a signal handler or modifying the handling of SIGALRM while you're sleeping will cause undefined results. undefined!! as in the universe makes no promises!! do not do this!! ๐Ÿ™ˆ

fr fr, undefined behavior means nobody can tell you what happens. not even the kernel. not even your most knowledgeable mutual. just don't.

๐Ÿ‘‘ SEE ALSO

sleep(1), alarm(2), nanosleep(2), signal(2), signal(7)


and that's the page, bestie!! this was pulled straight from Linux man-pages 6.20, dated 2026-02-08 ๐Ÿฉท sleep well, ily, go drink some water โœจ๐Ÿงš๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms