From 620b861bd508f5606f35b992f243fd90292df386 Mon Sep 17 00:00:00 2001 From: albert <> Date: Tue, 30 Sep 2003 04:00:50 +0000 Subject: [PATCH] Thread flags conflict --- ps/common.h | 9 +++++++-- ps/parser.c | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ps/common.h b/ps/common.h index f9f96ad1..d8f63152 100644 --- a/ps/common.h +++ b/ps/common.h @@ -94,8 +94,13 @@ #define needs_for_select (PROC_FILLSTAT | PROC_FILLSTATUS) /* thread_flags */ -#define TF_show_proc 0x0001 // show the summary line -#define TF_show_task 0x0002 // show the per-thread lines +#define TF_B_H 0x0001 +#define TF_B_m 0x0002 +#define TF_U_m 0x0004 +#define TF_U_T 0x0008 +#define TF_U_L 0x0010 +#define TF_show_proc 0x0100 // show the summary line +#define TF_show_task 0x0200 // show the per-thread lines /* personality control flags */ #define PER_BROKEN_o 0x0001 diff --git a/ps/parser.c b/ps/parser.c index 57d683fe..d9a91d7d 100644 --- a/ps/parser.c +++ b/ps/parser.c @@ -264,6 +264,7 @@ static const char *parse_sysv_option(void){ * SCO UnixWare uses -L too. */ trace("-L Print LWP (thread) info.\n"); + thread_flags |= TF_U_L; thread_flags |= TF_show_task; format_modifiers |= FM_L; break; @@ -299,6 +300,7 @@ static const char *parse_sysv_option(void){ * Also, testing shows PID==SPID for all normal processes. */ trace("-T adds strange SPID column (old sproc() threads?)\n"); + thread_flags |= TF_U_T; thread_flags |= TF_show_task; format_modifiers |= FM_T; break; @@ -371,6 +373,7 @@ static const char *parse_sysv_option(void){ case 'm': trace("-m shows threads.\n"); /* note that AIX shows 2 lines for a normal process */ + thread_flags |= TF_U_m; thread_flags |= TF_show_proc; thread_flags |= TF_show_task; break; @@ -503,6 +506,7 @@ static const char *parse_bsd_option(void){ #endif case 'H': // The FreeBSD way (NetBSD:s OpenBSD:k FreeBSD:H -- NIH???) trace("H Print LWP (thread) info.\n"); // was: Use /vmcore as c-dumpfile\n"); + thread_flags |= TF_B_H; thread_flags |= TF_show_task; // FIXME: determine if TF_show_proc is needed //format_modifiers |= FM_L; // FIXME: determine if we need something like this break; @@ -620,6 +624,7 @@ static const char *parse_bsd_option(void){ defer_sf_option("pmem", SF_B_m); break; } + thread_flags |= TF_B_m; thread_flags |= TF_show_proc; thread_flags |= TF_show_task; break; @@ -1095,6 +1100,19 @@ static void choose_dimensions(void){ /* perhaps --html and --null should set unlimited width */ } +static const char *thread_option_check(void){ + if(!thread_flags) return NULL; + + if((thread_flags&TF_B_H) && (thread_flags&(TF_B_m|TF_U_m))) + return "Thread flags conflict; can't use H with m or -m."; + if((thread_flags&TF_B_m) && (thread_flags&TF_U_m)) + return "Thread flags conflict; can't use both m and -m."; + if((thread_flags&TF_U_L) && (thread_flags&TF_U_T)) + return "Thread flags conflict; can't use both -L and -T."; + + return NULL; +} + int arg_parse(int argc, char *argv[]){ const char *err = NULL; const char *err2 = NULL; @@ -1102,17 +1120,14 @@ int arg_parse(int argc, char *argv[]){ ps_argv = argv; thisarg = 0; -#if 0 - {int debugloop = 0; while(debugloop