aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h76
1 files changed, 35 insertions, 41 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 481fad3a9b42..9da5aa0771ef 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -68,7 +68,7 @@ struct sched_param {
68#include <linux/smp.h> 68#include <linux/smp.h>
69#include <linux/sem.h> 69#include <linux/sem.h>
70#include <linux/signal.h> 70#include <linux/signal.h>
71#include <linux/fs_struct.h> 71#include <linux/path.h>
72#include <linux/compiler.h> 72#include <linux/compiler.h>
73#include <linux/completion.h> 73#include <linux/completion.h>
74#include <linux/pid.h> 74#include <linux/pid.h>
@@ -97,6 +97,7 @@ struct futex_pi_state;
97struct robust_list_head; 97struct robust_list_head;
98struct bio; 98struct bio;
99struct bts_tracer; 99struct bts_tracer;
100struct fs_struct;
100 101
101/* 102/*
102 * List of flags we want to share for kernel threads, 103 * List of flags we want to share for kernel threads,
@@ -547,25 +548,8 @@ struct signal_struct {
547 548
548 struct list_head cpu_timers[3]; 549 struct list_head cpu_timers[3];
549 550
550 /* job control IDs */
551
552 /*
553 * pgrp and session fields are deprecated.
554 * use the task_session_Xnr and task_pgrp_Xnr routines below
555 */
556
557 union {
558 pid_t pgrp __deprecated;
559 pid_t __pgrp;
560 };
561
562 struct pid *tty_old_pgrp; 551 struct pid *tty_old_pgrp;
563 552
564 union {
565 pid_t session __deprecated;
566 pid_t __session;
567 };
568
569 /* boolean value for session group leader */ 553 /* boolean value for session group leader */
570 int leader; 554 int leader;
571 555
@@ -1469,16 +1453,6 @@ static inline int rt_task(struct task_struct *p)
1469 return rt_prio(p->prio); 1453 return rt_prio(p->prio);
1470} 1454}
1471 1455
1472static inline void set_task_session(struct task_struct *tsk, pid_t session)
1473{
1474 tsk->signal->__session = session;
1475}
1476
1477static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
1478{
1479 tsk->signal->__pgrp = pgrp;
1480}
1481
1482static inline struct pid *task_pid(struct task_struct *task) 1456static inline struct pid *task_pid(struct task_struct *task)
1483{ 1457{
1484 return task->pids[PIDTYPE_PID].pid; 1458 return task->pids[PIDTYPE_PID].pid;
@@ -1489,6 +1463,11 @@ static inline struct pid *task_tgid(struct task_struct *task)
1489 return task->group_leader->pids[PIDTYPE_PID].pid; 1463 return task->group_leader->pids[PIDTYPE_PID].pid;
1490} 1464}
1491 1465
1466/*
1467 * Without tasklist or rcu lock it is not safe to dereference
1468 * the result of task_pgrp/task_session even if task == current,
1469 * we can race with another thread doing sys_setsid/sys_setpgid.
1470 */
1492static inline struct pid *task_pgrp(struct task_struct *task) 1471static inline struct pid *task_pgrp(struct task_struct *task)
1493{ 1472{
1494 return task->group_leader->pids[PIDTYPE_PGID].pid; 1473 return task->group_leader->pids[PIDTYPE_PGID].pid;
@@ -1514,17 +1493,23 @@ struct pid_namespace;
1514 * 1493 *
1515 * see also pid_nr() etc in include/linux/pid.h 1494 * see also pid_nr() etc in include/linux/pid.h
1516 */ 1495 */
1496pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
1497 struct pid_namespace *ns);
1517 1498
1518static inline pid_t task_pid_nr(struct task_struct *tsk) 1499static inline pid_t task_pid_nr(struct task_struct *tsk)
1519{ 1500{
1520 return tsk->pid; 1501 return tsk->pid;
1521} 1502}
1522 1503
1523pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 1504static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
1505 struct pid_namespace *ns)
1506{
1507 return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
1508}
1524 1509
1525static inline pid_t task_pid_vnr(struct task_struct *tsk) 1510static inline pid_t task_pid_vnr(struct task_struct *tsk)
1526{ 1511{
1527 return pid_vnr(task_pid(tsk)); 1512 return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
1528} 1513}
1529 1514
1530 1515
@@ -1541,31 +1526,34 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1541} 1526}
1542 1527
1543 1528
1544static inline pid_t task_pgrp_nr(struct task_struct *tsk) 1529static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
1530 struct pid_namespace *ns)
1545{ 1531{
1546 return tsk->signal->__pgrp; 1532 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
1547} 1533}
1548 1534
1549pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
1550
1551static inline pid_t task_pgrp_vnr(struct task_struct *tsk) 1535static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
1552{ 1536{
1553 return pid_vnr(task_pgrp(tsk)); 1537 return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
1554} 1538}
1555 1539
1556 1540
1557static inline pid_t task_session_nr(struct task_struct *tsk) 1541static inline pid_t task_session_nr_ns(struct task_struct *tsk,
1542 struct pid_namespace *ns)
1558{ 1543{
1559 return tsk->signal->__session; 1544 return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
1560} 1545}
1561 1546
1562pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
1563
1564static inline pid_t task_session_vnr(struct task_struct *tsk) 1547static inline pid_t task_session_vnr(struct task_struct *tsk)
1565{ 1548{
1566 return pid_vnr(task_session(tsk)); 1549 return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
1567} 1550}
1568 1551
1552/* obsolete, do not use */
1553static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1554{
1555 return task_pgrp_nr_ns(tsk, &init_pid_ns);
1556}
1569 1557
1570/** 1558/**
1571 * pid_alive - check that a task structure is not stale 1559 * pid_alive - check that a task structure is not stale
@@ -1975,7 +1963,8 @@ extern void mm_release(struct task_struct *, struct mm_struct *);
1975/* Allocate a new mm structure and copy contents from tsk->mm */ 1963/* Allocate a new mm structure and copy contents from tsk->mm */
1976extern struct mm_struct *dup_mm(struct task_struct *tsk); 1964extern struct mm_struct *dup_mm(struct task_struct *tsk);
1977 1965
1978extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); 1966extern int copy_thread(unsigned long, unsigned long, unsigned long,
1967 struct task_struct *, struct pt_regs *);
1979extern void flush_thread(void); 1968extern void flush_thread(void);
1980extern void exit_thread(void); 1969extern void exit_thread(void);
1981 1970
@@ -2060,6 +2049,11 @@ static inline int thread_group_empty(struct task_struct *p)
2060#define delay_group_leader(p) \ 2049#define delay_group_leader(p) \
2061 (thread_group_leader(p) && !thread_group_empty(p)) 2050 (thread_group_leader(p) && !thread_group_empty(p))
2062 2051
2052static inline int task_detached(struct task_struct *p)
2053{
2054 return p->exit_signal == -1;
2055}
2056
2063/* 2057/*
2064 * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring 2058 * Protects ->fs, ->files, ->mm, ->group_info, ->comm, keyring
2065 * subscriptions and synchronises with wait4(). Also used in procfs. Also 2059 * subscriptions and synchronises with wait4(). Also used in procfs. Also