Skip to content

Commit ad86622

Browse files
oleg-nesterovtorvalds
authored andcommitted
wait: swap EXIT_ZOMBIE and EXIT_DEAD to hide EXIT_TRACE from user-space
get_task_state() uses the most significant bit to report the state to user-space, this means that EXIT_ZOMBIE->EXIT_TRACE->EXIT_DEAD transition can be noticed via /proc as Z -> X -> Z change. Note that this was possible even before EXIT_TRACE was introduced. This is not really bad but imho it make sense to hide EXIT_TRACE from user-space completely. So the patch simply swaps EXIT_ZOMBIE and EXIT_DEAD, this way EXIT_TRACE will be seen as EXIT_ZOMBIE by user-space. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Jan Kratochvil <jan.kratochvil@redhat.com> Cc: Michal Schmidt <mschmidt@redhat.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Lennart Poettering <lpoetter@redhat.com> Cc: Roland McGrath <roland@hack.frob.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b3ab031 commit ad86622

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎fs/proc/array.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ static const char * const task_state_array[] = {
138138
"D (disk sleep)", /* 2 */
139139
"T (stopped)", /* 4 */
140140
"t (tracing stop)", /* 8 */
141-
"Z (zombie)", /* 16 */
142-
"X (dead)", /* 32 */
141+
"X (dead)", /* 16 */
142+
"Z (zombie)", /* 32 */
143143
};
144144

145145
static inline const char *get_task_state(struct task_struct *tsk)

‎include/linux/sched.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
210210
#define __TASK_STOPPED 4
211211
#define __TASK_TRACED 8
212212
/* in tsk->exit_state */
213-
#define EXIT_ZOMBIE 16
214-
#define EXIT_DEAD 32
213+
#define EXIT_DEAD 16
214+
#define EXIT_ZOMBIE 32
215215
#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
216216
/* in tsk->state again */
217217
#define TASK_DEAD 64

0 commit comments

Comments
 (0)