KEYCTL_SET_TIMEOUT(2const)
β¨ KEYCTL_SET_TIMEOUT β¨
okay so bestie, we're in the Linux manual pages, section 2const (that's the const-y corner of syscalls), and today's hyperfixation is KEYCTL_SET_TIMEOUT β literally just set the expiration timer on a key. putting an alarm clock on your key. giving it a bedtime. iconic behavior honestly π
π LIBRARY
Standard C library (libc, -lc) β the classic, the blueprint, the moment π
π¦ SYNOPSIS
#include <linux/keyctl.h> /* Definition of KEY* constants */
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>
long syscall(SYS_keyctl, KEYCTL_SET_TIMEOUT, key_serial_t key, time_t t);
like yes we're doing the raw syscall dance, no shame in it π«Ά
π DESCRIPTION
So. You set a timeout on a key. That's the whole vibe. Let's break it down fr fr.
- The ID of the key goes in
key. - The timeout value, counted in seconds from the current time, goes in
t. - The timeout is measured against the realtime clock β° β so yes, the wall-clock one, the one that jumps when your laptop syncs time, that one.
Now the fun part: if you pass the timeout value as 0, it clears any existing timeout on the key. poof. gone. not a timeout anymore, it's a free spirit π
Wanna know how much time a key has left? The /proc/keys file displays the remaining time until each key will expire. and lowkey that's the only method of discovering the timeout on a key β there is no other way bestie, that's the whole pipeline π
Permission check moment: the caller must either have the setattr permission on the key or hold an instantiation authorization token for the key (see request_key(2)). no permission, no timer, no service π
Once that timeout expires, the key and any links to the key will be automatically garbage collected. like, swept up. and then any subsequent attempts to access the key will fail with the error EKEYEXPIRED. it's giving ghosted π
β οΈ HEADS UP: this operation cannot be used to set timeouts on revoked, expired, or negatively instantiated keys. not happening. do not try it. the key said no β
π₯ RETURN VALUE
- On success,
0is returned. slay β¨ - On error,
-1is returned, anderrnois set to indicate the error. rude but informative π
πΈ VERSIONS
A wrapper is provided in the libkeyutils library: keyctl_set_timeout(3). so if you'd rather not raw-dog the syscall, there's a whole library waiting for you π
π STANDARDS
Linux. (obviously. we're built different here.)
β HISTORY
Linux 2.6.16. vintage but still ate π
π SEE ALSO
mwah π that's the page, bestie β go forth and schedule your keys' little deaths. source vibes: Linux man-pages 6.20, dated 2026-02-08, from the KEYCTL_SET_TIMEOUT(2const) page itself. no cap, every word was already there. I just made it cute. π¦
π¦ 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 2016, Michael Kerrisk <mtk.manpages@gmail.com>
- Copyright 2016, Eugene Syromyatnikov <evgsyr@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms