drivers/tty/tty_jobctrl.c
Source file repositories/reference/linux-study-clean/drivers/tty/tty_jobctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/tty_jobctrl.c- Extension
.c- Size
- 15115 bytes
- Lines
- 594
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/errno.hlinux/signal.hlinux/sched/signal.hlinux/sched/task.hlinux/tty.hlinux/fcntl.hlinux/uaccess.htty.h
Detected Declarations
function Copyrightfunction __tty_check_changefunction tty_check_changefunction proc_clear_ttyfunction __proc_set_ttyfunction proc_set_ttyfunction tty_openfunction tty_releasefunction do_each_pid_taskfunction tty_signal_session_leaderfunction do_each_pid_taskfunction no_ttyfunction no_ttyfunction tty_lockfunction tiocgpgrpfunction tiocspgrpfunction tiocgsidfunction tty_ioctlexport tty_check_changeexport get_current_ttyexport tty_get_pgrp
Annotated Snippet
if (is_ignored(sig)) {
if (sig == SIGTTIN)
ret = -EIO;
} else if (is_current_pgrp_orphaned())
ret = -EIO;
else {
kill_pgrp(pgrp, sig, 1);
set_thread_flag(TIF_SIGPENDING);
ret = -ERESTARTSYS;
}
}
rcu_read_unlock();
if (!tty_pgrp)
tty_warn(tty, "sig=%d, tty->pgrp == NULL!\n", sig);
return ret;
}
int tty_check_change(struct tty_struct *tty)
{
return __tty_check_change(tty, SIGTTOU);
}
EXPORT_SYMBOL(tty_check_change);
void proc_clear_tty(struct task_struct *p)
{
unsigned long flags;
struct tty_struct *tty;
spin_lock_irqsave(&p->sighand->siglock, flags);
tty = p->signal->tty;
p->signal->tty = NULL;
spin_unlock_irqrestore(&p->sighand->siglock, flags);
tty_kref_put(tty);
}
/**
* __proc_set_tty - set the controlling terminal
* @tty: tty structure
*
* Only callable by the session leader and only if it does not already have
* a controlling terminal.
*
* Caller must hold: tty_lock()
* a readlock on tasklist_lock
* sighand lock
*/
static void __proc_set_tty(struct tty_struct *tty)
{
unsigned long flags;
spin_lock_irqsave(&tty->ctrl.lock, flags);
/*
* The session and fg pgrp references will be non-NULL if
* tiocsctty() is stealing the controlling tty
*/
put_pid(tty->ctrl.session);
put_pid(tty->ctrl.pgrp);
tty->ctrl.pgrp = get_pid(task_pgrp(current));
tty->ctrl.session = get_pid(task_session(current));
spin_unlock_irqrestore(&tty->ctrl.lock, flags);
if (current->signal->tty) {
tty_debug(tty, "current tty %s not NULL!!\n",
current->signal->tty->name);
tty_kref_put(current->signal->tty);
}
put_pid(current->signal->tty_old_pgrp);
current->signal->tty = tty_kref_get(tty);
current->signal->tty_old_pgrp = NULL;
}
static void proc_set_tty(struct tty_struct *tty)
{
spin_lock_irq(¤t->sighand->siglock);
__proc_set_tty(tty);
spin_unlock_irq(¤t->sighand->siglock);
}
/*
* Called by tty_open() to set the controlling tty if applicable.
*/
void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty)
{
read_lock(&tasklist_lock);
spin_lock_irq(¤t->sighand->siglock);
if (current->signal->leader &&
!current->signal->tty &&
tty->ctrl.session == NULL) {
/*
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/signal.h`, `linux/sched/signal.h`, `linux/sched/task.h`, `linux/tty.h`, `linux/fcntl.h`, `linux/uaccess.h`.
- Detected declarations: `function Copyright`, `function __tty_check_change`, `function tty_check_change`, `function proc_clear_tty`, `function __proc_set_tty`, `function proc_set_tty`, `function tty_open`, `function tty_release`, `function do_each_pid_task`, `function tty_signal_session_leader`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.