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
- Copyright 1993, Thomas Koenig <ig25@rz.uni-karlsruhe.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms