arch/um/os-Linux/process.c
Source file repositories/reference/linux-study-clean/arch/um/os-Linux/process.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/os-Linux/process.c- Extension
.c- Size
- 4112 bytes
- Lines
- 212
- 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.
Dependency Surface
stdio.hstdlib.hunistd.herrno.hsignal.hfcntl.hlimits.hlinux/futex.hsys/mman.hsys/ptrace.hsys/prctl.hsys/wait.hasm/unistd.hinit.hlongjmp.hos.hskas/skas.h
Detected Declarations
function Copyrightfunction os_kill_processfunction os_kill_ptraced_processfunction os_reap_childfunction os_getpidfunction os_map_memoryfunction os_protect_memoryfunction os_unmap_memoryfunction os_drop_memoryfunction can_drop_memoryfunction init_new_thread_signalsfunction os_set_pdeathsigfunction os_futex_waitfunction os_futex_wake
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <limits.h>
#include <linux/futex.h>
#include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <asm/unistd.h>
#include <init.h>
#include <longjmp.h>
#include <os.h>
#include <skas/skas.h>
void os_alarm_process(int pid)
{
if (pid <= 0)
return;
kill(pid, SIGALRM);
}
void os_kill_process(int pid, int reap_child)
{
if (pid <= 0)
return;
/* Block signals until child is reaped */
block_signals();
kill(pid, SIGKILL);
if (reap_child)
CATCH_EINTR(waitpid(pid, NULL, __WALL));
unblock_signals();
}
/* Kill off a ptraced child by all means available. kill it normally first,
* then PTRACE_KILL it, then PTRACE_CONT it in case it's in a run state from
* which it can't exit directly.
*/
void os_kill_ptraced_process(int pid, int reap_child)
{
if (pid <= 0)
return;
/* Block signals until child is reaped */
block_signals();
kill(pid, SIGKILL);
ptrace(PTRACE_KILL, pid);
ptrace(PTRACE_CONT, pid);
if (reap_child)
CATCH_EINTR(waitpid(pid, NULL, __WALL));
unblock_signals();
}
pid_t os_reap_child(void)
{
int status;
/* Try to reap a child */
return waitpid(-1, &status, WNOHANG);
}
/* Don't use the glibc version, which caches the result in TLS. It misses some
* syscalls, and also breaks with clone(), which does not unshare the TLS.
*/
int os_getpid(void)
{
return syscall(__NR_getpid);
}
int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
int r, int w, int x)
{
void *loc;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `unistd.h`, `errno.h`, `signal.h`, `fcntl.h`, `limits.h`, `linux/futex.h`.
- Detected declarations: `function Copyright`, `function os_kill_process`, `function os_kill_ptraced_process`, `function os_reap_child`, `function os_getpid`, `function os_map_memory`, `function os_protect_memory`, `function os_unmap_memory`, `function os_drop_memory`, `function can_drop_memory`.
- 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.