SIGIO_INIT(9)
π SIGIO_INIT(9) β the async IO signal API, explained by your favorite kernel gremlin
okay so this is a page from the Kernel Developer's Manual (yes, section 9, the cool section) and it's all about sigio_init, sigio_free, sigio_copy, sigio_setown, and sigio_getown β aka the asynchronous IO signal API. bestie, it's giving "who do I send this signal to" energy and honestly it ate. π
β¨ SYNOPSIS β¨
like, here's the whole cast, literally verbatim:
#include <sys/sigio.h>
void
sigio_init(struct sigio_ref *sir);
void
sigio_free(struct sigio_ref *sir);
void
sigio_copy(struct sigio_ref *dst, struct sigio_ref *src);
int
sigio_setown(struct sigio_ref *sir, u_long cmd, caddr_t data);
pid_t
sigio_getown(struct sigio_ref *sir, u_long cmd, caddr_t data);
look at them. five little functions. iconic. π
πΈ DESCRIPTION πΈ
so the asynchronous IO signal API provides a means to manage signal registrations. basically it associates a process or process group with a signal source β like setting them up on a little blind date, except the date gets automatically cancelled. and no cap: the association is revoked automatically when the process or process group is deleted. no lingering situationships. π¦
now let me introduce each one:
sigio_init()initializes the sigio referencesir. fresh start, clean slate, main character energy.sigio_free()clears any process or process group associated with referencesir. bye bestie πsigio_copy()copies the registration from referencesrcto referencedst. it's giving "you get what she has."sigio_setown()associates the referencesirwith a process or process group. here's the tea:cmdis one of the ioctl commandsFIOSETOWN,SIOCSPGRP, andTIOCSPGRP. anddatais a pointer to a signed integer that represents the ID of the owner of the registration. so like, who's the owner? that'sdata's job to say.- for
FIOSETOWNandSIOCSPGRP, a positive ID is taken as a process ID, and a negative ID is taken as a process group ID. - if
cmdisTIOCSPGRP, a positive ID is taken as a process group ID, and negative ID values are not allowed. π« - for all values of
cmd, the referencesiris cleared if the ID is zero. zero = nobody home.
- for
sigio_getown()stores the ID of the process or process group associated with the referencesirto the signed integer pointed bydata. thecmdhere is one of the ioctl commandsFIOGETOWN,SIOCGPGRP, andTIOCGPGRP.- for
FIOGETOWNandSIOCGPGRP, a process ID is stored as a positive ID, and a process group ID is stored as a negative ID. - for
TIOCGPGRP, a process ID is stored as a negative ID, and a process group ID is stored as a positive ID. yes the signs flip, no I don't make the rules, that's just how it is π - if there is no registered owner, a zero is stored in the integer. empty roster, as they say.
- for
π«Ά little certified-facts-only aside: whensigio_setown()is called, the invoking process' credentials are stored in the reference. these credentials are checked when the reference is used withpgsigio(9). so yeah, it remembers who did it. iykyk.
π§ CONTEXT π§
sigio_init(), sigio_free(), sigio_copy(), sigio_setown() and sigio_getown() can be called during autoconf, or from process context. flexible queens. β¨
π RETURN VALUES π
sigio_setown() returns 0 on success. slay. otherwise, these error values come back at you:
[EINVAL]β the process group ID is invalid.[EPERM]β the invoking process belongs to another session than the process or process group. not your session, not your problem π₯[ESRCH]β the process or process group does not exist.[ESRCH]β the process is exiting. (yeah, same error, different reason, don't come for me π)
π SEE ALSO π
β HISTORY β
the sigio routines were adapted from FreeBSD and first appeared in OpenBSD 6.5. glow-up arc fr fr. π
and that's the whole page, bestie. no skips, no cuts, every flag and error intact. π
π this manual page is dated January 8, 2020, comes from Debian, and lives in section 9. mwah, go forth and register your signals responsibly. π
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 2018 Visa Hankala
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms