Skip to content

Commit

Permalink
[PATCH] add process_session() helper routine: deprecate old field
Browse files Browse the repository at this point in the history
Add an anonymous union and ((deprecated)) to catch direct usage of the
session field.

[[email protected]: fix various missed conversions]
[[email protected]: fix UML bug]
Signed-off-by: Jeff Dike <[email protected]>
Cc: Cedric Le Goater <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Cedric Le Goater authored and Linus Torvalds committed Dec 8, 2006
1 parent 937949d commit 1ec320a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3855,7 +3855,7 @@ EXPORT_SYMBOL(proc_clear_tty);
void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
{
if (tty) {
tty->session = tsk->signal->session;
tty->session = process_session(tsk);
tty->pgrp = process_group(tsk);
}
tsk->signal->tty = tty;
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
stime = cputime_add(stime, sig->stime);
}

sid = sig->session;
sid = signal_session(sig);
pgid = process_group(task);
ppid = rcu_dereference(task->real_parent)->tgid;

Expand Down
11 changes: 6 additions & 5 deletions include/linux/init_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,18 @@
.cpu_vm_mask = CPU_MASK_ALL, \
}

#define INIT_SIGNALS(sig) { \
.count = ATOMIC_INIT(1), \
#define INIT_SIGNALS(sig) { \
.count = ATOMIC_INIT(1), \
.wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
.shared_pending = { \
.shared_pending = { \
.list = LIST_HEAD_INIT(sig.shared_pending.list), \
.signal = {{0}}}, \
.signal = {{0}}}, \
.posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
.cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
.rlim = INIT_RLIMITS, \
.pgrp = 1, \
.session = 1, \
.tty_old_pgrp = 0, \
{ .__session = 1}, \
}

extern struct nsproxy init_nsproxy;
Expand Down
19 changes: 17 additions & 2 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,12 @@ struct signal_struct {
/* job control IDs */
pid_t pgrp;
pid_t tty_old_pgrp;
pid_t session;

union {
pid_t session __deprecated;
pid_t __session;
};

/* boolean value for session group leader */
int leader;

Expand Down Expand Up @@ -1047,9 +1052,19 @@ static inline pid_t process_group(struct task_struct *tsk)
return tsk->signal->pgrp;
}

static inline pid_t signal_session(struct signal_struct *sig)
{
return sig->__session;
}

static inline pid_t process_session(struct task_struct *tsk)
{
return tsk->signal->session;
return signal_session(tsk->signal);
}

static inline void set_signal_session(struct signal_struct *sig, pid_t session)
{
sig->__session = session;
}

static inline struct pid *task_pid(struct task_struct *task)
Expand Down
2 changes: 1 addition & 1 deletion kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void __set_special_pids(pid_t session, pid_t pgrp)

if (process_session(curr) != session) {
detach_pid(curr, PIDTYPE_SID);
curr->signal->session = session;
set_signal_session(curr->signal, session);
attach_pid(curr, PIDTYPE_SID, session);
}
if (process_group(curr) != pgrp) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
if (thread_group_leader(p)) {
p->signal->tty = current->signal->tty;
p->signal->pgrp = process_group(current);
p->signal->session = process_session(current);
set_signal_session(p->signal, process_session(current));
attach_pid(p, PIDTYPE_PGID, process_group(p));
attach_pid(p, PIDTYPE_SID, process_session(p));

Expand Down

0 comments on commit 1ec320a

Please sign in to comment.