arch/um/os-Linux/sigio.c
Source file repositories/reference/linux-study-clean/arch/um/os-Linux/sigio.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/os-Linux/sigio.c- Extension
.c- Size
- 5857 bytes
- Lines
- 305
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
unistd.herrno.hfcntl.hpoll.hpty.hsched.hsignal.hstring.hsys/epoll.hasm/unistd.hkern_util.hinit.hos.hsigio.hum_malloc.h
Detected Declarations
struct openpty_argfunction __add_sigio_fdfunction add_sigio_fdfunction __ignore_sigio_fdfunction ignore_sigio_fdfunction write_sigio_workaroundfunction sigio_brokenfunction maybe_sigio_brokenfunction sigio_cleanupfunction handlerfunction openpty_cbfunction async_ptyfunction check_one_sigiofunction tty_outputfunction check_sigiofunction os_check_bugs
Annotated Snippet
struct openpty_arg {
int master;
int slave;
int err;
};
static void openpty_cb(void *arg)
{
struct openpty_arg *info = arg;
info->err = 0;
if (openpty(&info->master, &info->slave, NULL, NULL, NULL))
info->err = -errno;
}
static int async_pty(int master, int slave)
{
int flags;
flags = fcntl(master, F_GETFL);
if (flags < 0)
return -errno;
if ((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
(fcntl(master, F_SETOWN, os_getpid()) < 0))
return -errno;
if ((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
return -errno;
return 0;
}
static void __init check_one_sigio(void (*proc)(int, int))
{
struct sigaction old, new;
struct openpty_arg pty = { .master = -1, .slave = -1 };
int master, slave, err;
initial_thread_cb(openpty_cb, &pty);
if (pty.err) {
printk(UM_KERN_ERR "check_one_sigio failed, errno = %d\n",
-pty.err);
return;
}
master = pty.master;
slave = pty.slave;
if ((master == -1) || (slave == -1)) {
printk(UM_KERN_ERR "check_one_sigio failed to allocate a "
"pty\n");
return;
}
/* Not now, but complain so we now where we failed. */
err = raw(master);
if (err < 0) {
printk(UM_KERN_ERR "check_one_sigio : raw failed, errno = %d\n",
-err);
return;
}
err = async_pty(master, slave);
if (err < 0) {
printk(UM_KERN_ERR "check_one_sigio : sigio_async failed, "
"err = %d\n", -err);
return;
}
if (sigaction(SIGIO, NULL, &old) < 0) {
printk(UM_KERN_ERR "check_one_sigio : sigaction 1 failed, "
"errno = %d\n", errno);
return;
}
new = old;
new.sa_handler = handler;
if (sigaction(SIGIO, &new, NULL) < 0) {
printk(UM_KERN_ERR "check_one_sigio : sigaction 2 failed, "
"errno = %d\n", errno);
return;
}
got_sigio = 0;
(*proc)(master, slave);
close(master);
close(slave);
Annotation
- Immediate include surface: `unistd.h`, `errno.h`, `fcntl.h`, `poll.h`, `pty.h`, `sched.h`, `signal.h`, `string.h`.
- Detected declarations: `struct openpty_arg`, `function __add_sigio_fd`, `function add_sigio_fd`, `function __ignore_sigio_fd`, `function ignore_sigio_fd`, `function write_sigio_workaround`, `function sigio_broken`, `function maybe_sigio_broken`, `function sigio_cleanup`, `function handler`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.