KLDUNLOAD(2)
β¨ KLDUNLOAD β bestie's guide to yeeting kernel modules β¨
okay so real talk, this is the kldunload / kldunloadf manual page, and it's giving unload kld files energy π if you're here, you're the kind of girl who loads a kernel module and then goes "β¦actually no" and that is VALID.
π LIBRARY
Standard C Library (libc, -lc) π like obviously, she lives in libc, that's her home.
β¨ SYNOPSIS
#include <sys/param.h>
#include <sys/linker.h>
int
kldunload(int fileid);
int
kldunloadf(int fileid, int flags);
look at her. two little functions. so demure. so mindful. π¦
π DESCRIPTION
okay so the kldunload() system call unloads a kld file from the kernel that was previously linked via kldload(2). basically it's the "undo" button for modules, and no cap, we love a reversible decision π«Ά
the kldunloadf() system call is the same girl but she takes an additional flags argument, and that flags can be one of these two:
LINKER_UNLOAD_NORMALβ gives you the exact same behavior askldunload(), i.e. the classic. the OG. the default vibe. β¨LINKER_UNLOAD_FORCEβ this one causes the unload to ignore a failure to quiesce the module. yes bestie she said what she said, she's not waiting for the module to calm down, she's just leaving π
π«Ά RETURN VALUES
upon successful completion, the value 0 is returned. otherwise the value -1 is returned and the global variable errno is set to indicate the error. so like. 0 = slay, -1 = check errno, periodt. π
π ERRORS
the file referred to by fileid is unloaded unless one of these happens (and if one happens, bestie, she is NOT unloading):
[EPERM]β you do not have access to unlink the file from the kernel. not your module, not your business π[ENOENT]β the file was not found. she's not there. she never was. ghosted fr fr.[EBUSY]β you attempted to unload a file linked by the kernel. nope. the kernel is holding on with both hands. π[EINVAL]β thekldunloadf()system call was passed invalid flags. you handed her something she doesn't recognize and she's judging you (gently, lovingly) π
π SEE ALSO
kldfind(2), kldfirstmod(2), kldload(2), kldnext(2), kldstat(2), kldsym(2), modfind(2), modfnext(2), modnext(2), modstat(2), kld(4), kldunload(8) β the whole friend group, go say hi, they're all iconic in their own way π
πΈ HISTORY
the kld interface first appeared in FreeBSD 3.0. she's a legacy queen and she's been serving since day one π
π‘ friendly reminder bestie: unload responsibly. LINKER_UNLOAD_FORCE is right there and it does exactly what it sounds like it does.
and that's the whole page!! this came from the Debian edition, dated December 25, 2008 β a lil Christmas gift of a manpage π β and honestly? she ate. mwah. π πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1999 Chris Costello
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms