aboutsummaryrefslogtreecommitdiff
path: root/utils/portinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/portinfo.c')
-rw-r--r--utils/portinfo.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/utils/portinfo.c b/utils/portinfo.c
index 10f5fe8f..e78c77df 100644
--- a/utils/portinfo.c
+++ b/utils/portinfo.c
@@ -1,6 +1,6 @@
/* Print information about a task's ports
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,98,99, 2000 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <version.h>
#include <mach.h>
@@ -34,15 +35,17 @@
#include <portinfo.h>
#include <portxlate.h>
-char *argp_program_version = "portinfo 1.0 (GNU " HURD_RELEASE ")";
+const char *argp_program_version = STANDARD_HURD_VERSION (portinfo);
static const struct argp_option options[] = {
{0,0,0,0,0, 1},
{"verbose", 'v', 0, 0, "Give more detailed information"},
{"members", 'm', 0, 0, "Show members of port-sets"},
{"hex-names", 'x', 0, 0, "Show port names in hexadecimal"},
+#if 0 /* XXX implement this */
{"query-process", 'q', 0, 0, "Query the process itself for the identity of"
" the ports in question -- requires the process be in a sane state"},
+#endif
{"hold", '*', 0, OPTION_HIDDEN},
{0,0,0,0, "Selecting which names to show:", 2},
@@ -54,8 +57,10 @@ static const struct argp_option options[] = {
{0,0,0,0, "Translating port names between tasks:", 3},
{"translate", 't', "PID", 0, "Translate port names to process PID"},
+#if 0
{"show-targets", 'h', 0, 0,
"Print a header describing the target process" },
+#endif
{"no-translation-errors", 'E', 0, 0,
"Don't display an error if a specified port can't be translated" },
#if 0
@@ -63,16 +68,18 @@ static const struct argp_option options[] = {
{"target-receive", 'R', 0, 0,
"Only show ports that translate into receive rights"},
{"target-send", 'S', 0, 0,
- "Only show ports that translate into receive rights"},
+ "Only show ports that translate into send rights"},
{"target-send-once",'O', 0, 0,
- "Only show ports that translate into receive rights"},
+ "Only show ports that translate into send-once rights"},
+ "Only show ports that translate into send once rights"},
#endif
{0}
};
static const char *args_doc = "PID [NAME...]";
static const char *doc =
-"If no port NAMEs are given, all ports in process PID are reported (if"
+"Show information about mach ports NAME... (default all ports) in process PID."
+"\vIf no port NAMEs are given, all ports in process PID are reported (if"
" translation is used, then only those common to both processes). NAMEs"
" may be specified in hexadecimal or octal by using a 0x or 0 prefix.";
@@ -96,11 +103,13 @@ parse_task (char *arg)
err = proc_pid2task (proc, pid, &task);
if (err)
error (11, err, "%s", arg);
+ else if (task == MACH_PORT_NULL)
+ error (11, 0, "%s: Process %d is dead and has no task", arg, (int) pid);
return task;
}
-static volatile hold = 0;
+static volatile int hold = 0;
int
main (int argc, char **argv)
@@ -111,6 +120,7 @@ main (int argc, char **argv)
unsigned show = 0; /* what info we print */
mach_port_type_t only = 0, target_only = 0; /* Which names to show */
task_t xlate_task = MACH_PORT_NULL;
+ int no_translation_errors = 0; /* inhibit complaints about bad names */
struct port_name_xlator *xlator = 0;
/* Parse our options... */
@@ -134,6 +144,7 @@ main (int argc, char **argv)
case 't': xlate_task = parse_task (arg); break;
case 'a': search = 1; break;
+ case 'E': no_translation_errors = 1; break;
case '*':
hold = 1;
@@ -189,7 +200,12 @@ main (int argc, char **argv)
else
{
if (xlator)
- err = print_xlated_port_info (name, 0, xlator, show, stdout);
+ {
+ err = print_xlated_port_info (name, 0, xlator,
+ show, stdout);
+ if (err && no_translation_errors)
+ break;
+ }
else
err = print_port_info (name, 0, task, show, stdout);
if (err)