aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-19 02:40:39 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:43 -0400
commit9a2e70572e94e21e7ec4186702d045415422bda0 (patch)
treea6cd54dc559cbf6840dac4077f507a961486e21b
parent270f722d4d5f94b02fd48eed47e57917ab00a858 (diff)
Isolate the explicit usage of signal->pgrp
The pgrp field is not used widely around the kernel so it is now marked as deprecated with appropriate comment. The initialization of INIT_SIGNALS is trimmed because a) they are set to 0 automatically; b) gcc cannot properly initialize two anonymous (the second one is the one with the session) unions. In this particular case to make it compile we'd have to add some field initialized right before the .pgrp. This is the same patch as the 1ec320afdc9552c92191d5f89fcd1ebe588334ca one (from Cedric), but for the pgrp field. Some progress report: We have to deprecate the pid, tgid, session and pgrp fields on struct task_struct and struct signal_struct. The session and pgrp are already deprecated. The tgid value is close to being such - the worst known usage in in fs/locks.c and audit code. The pid field deprecation is mainly blocked by numerous printk-s around the kernel that print the tsk->pid to log. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Serge Hallyn <serue@us.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/init_task.h3
-rw-r--r--include/linux/sched.h19
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c4
-rw-r--r--kernel/sys.c2
5 files changed, 21 insertions, 9 deletions
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 5ac5945696a0..cae35b6b9aec 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -67,9 +67,6 @@
67 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ 67 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
68 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ 68 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
69 .rlim = INIT_RLIMITS, \ 69 .rlim = INIT_RLIMITS, \
70 .pgrp = 0, \
71 .tty_old_pgrp = NULL, \
72 { .__session = 0}, \
73} 70}
74 71
75extern struct nsproxy init_nsproxy; 72extern struct nsproxy init_nsproxy;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4bbbe12880d7..13df99fb2769 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -429,7 +429,17 @@ struct signal_struct {
429 cputime_t it_prof_incr, it_virt_incr; 429 cputime_t it_prof_incr, it_virt_incr;
430 430
431 /* job control IDs */ 431 /* job control IDs */
432 pid_t pgrp; 432
433 /*
434 * pgrp and session fields are deprecated.
435 * use the task_session_Xnr and task_pgrp_Xnr routines below
436 */
437
438 union {
439 pid_t pgrp __deprecated;
440 pid_t __pgrp;
441 };
442
433 struct pid *tty_old_pgrp; 443 struct pid *tty_old_pgrp;
434 444
435 union { 445 union {
@@ -1196,6 +1206,11 @@ static inline void set_task_session(struct task_struct *tsk, pid_t session)
1196 tsk->signal->__session = session; 1206 tsk->signal->__session = session;
1197} 1207}
1198 1208
1209static inline void set_task_pgrp(struct task_struct *tsk, pid_t pgrp)
1210{
1211 tsk->signal->__pgrp = pgrp;
1212}
1213
1199static inline struct pid *task_pid(struct task_struct *task) 1214static inline struct pid *task_pid(struct task_struct *task)
1200{ 1215{
1201 return task->pids[PIDTYPE_PID].pid; 1216 return task->pids[PIDTYPE_PID].pid;
@@ -1268,7 +1283,7 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1268 1283
1269static inline pid_t task_pgrp_nr(struct task_struct *tsk) 1284static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1270{ 1285{
1271 return tsk->signal->pgrp; 1286 return tsk->signal->__pgrp;
1272} 1287}
1273 1288
1274pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); 1289pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
diff --git a/kernel/exit.c b/kernel/exit.c
index 68d27039ef7d..6838d4d77e05 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -306,7 +306,7 @@ void __set_special_pids(pid_t session, pid_t pgrp)
306 } 306 }
307 if (task_pgrp_nr(curr) != pgrp) { 307 if (task_pgrp_nr(curr) != pgrp) {
308 detach_pid(curr, PIDTYPE_PGID); 308 detach_pid(curr, PIDTYPE_PGID);
309 curr->signal->pgrp = pgrp; 309 set_task_pgrp(curr, pgrp);
310 attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp)); 310 attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp));
311 } 311 }
312} 312}
diff --git a/kernel/fork.c b/kernel/fork.c
index 240aa6601f5b..9d40367dd5db 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1293,13 +1293,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1293 if (clone_flags & CLONE_NEWPID) { 1293 if (clone_flags & CLONE_NEWPID) {
1294 p->nsproxy->pid_ns->child_reaper = p; 1294 p->nsproxy->pid_ns->child_reaper = p;
1295 p->signal->tty = NULL; 1295 p->signal->tty = NULL;
1296 p->signal->pgrp = p->pid; 1296 set_task_pgrp(p, p->pid);
1297 set_task_session(p, p->pid); 1297 set_task_session(p, p->pid);
1298 attach_pid(p, PIDTYPE_PGID, pid); 1298 attach_pid(p, PIDTYPE_PGID, pid);
1299 attach_pid(p, PIDTYPE_SID, pid); 1299 attach_pid(p, PIDTYPE_SID, pid);
1300 } else { 1300 } else {
1301 p->signal->tty = current->signal->tty; 1301 p->signal->tty = current->signal->tty;
1302 p->signal->pgrp = task_pgrp_nr(current); 1302 set_task_pgrp(p, task_pgrp_nr(current));
1303 set_task_session(p, task_session_nr(current)); 1303 set_task_session(p, task_session_nr(current));
1304 attach_pid(p, PIDTYPE_PGID, 1304 attach_pid(p, PIDTYPE_PGID,
1305 task_pgrp(current)); 1305 task_pgrp(current));
diff --git a/kernel/sys.c b/kernel/sys.c
index 2befc299129d..304b5410d746 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -977,7 +977,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
977 detach_pid(p, PIDTYPE_PGID); 977 detach_pid(p, PIDTYPE_PGID);
978 pid = find_vpid(pgid); 978 pid = find_vpid(pgid);
979 attach_pid(p, PIDTYPE_PGID, pid); 979 attach_pid(p, PIDTYPE_PGID, pid);
980 p->signal->pgrp = pid_nr(pid); 980 set_task_pgrp(p, pid_nr(pid));
981 } 981 }
982 982
983 err = 0; 983 err = 0;