|
From: <sv...@va...> - 2014-12-21 17:32:02
|
Author: philippe
Date: Sun Dec 21 17:31:54 2014
New Revision: 14827
Log:
Follow up to rev 14823: make errors when reporting command line non critical
(as e.g. cmdline reporting is not available on MacOS)
Modified:
trunk/coregrind/vgdb.c
Modified: trunk/coregrind/vgdb.c
==============================================================================
--- trunk/coregrind/vgdb.c (original)
+++ trunk/coregrind/vgdb.c Sun Dec 21 17:31:54 2014
@@ -1062,7 +1062,10 @@
}
/* report to user the existence of a vgdb-able valgrind process
- with given pid */
+ with given pid.
+ Note: this function does not exit (XERROR0 if an error is encountered
+ while producing the command line for pid, as this is not critical
+ and at least on MacOS, reading cmdline is not available. */
static
void report_pid (int pid, Bool on_stdout)
{
@@ -1070,30 +1073,28 @@
int fd, i;
FILE *out = on_stdout ? stdout : stderr;
+ fprintf(out, "use --pid=%d for ", pid);
+
sprintf(cmdline_file, "/proc/%d/cmdline", pid);
fd = open (cmdline_file, O_RDONLY);
if (fd == -1) {
DEBUG(1, "error opening cmdline file %s %s\n",
cmdline_file, strerror(errno));
- XERROR(errno, "could not open process command line for pid %d\n", pid);
+ fprintf(out, "(could not open process command line)\n");
} else {
char cmdline[100];
ssize_t sz;
-
- fprintf(out, "use --pid=%d for ", pid);
while ((sz = read(fd, cmdline, sizeof cmdline - 1)) != 0) {
- if (sz == -1) {
- DEBUG(1, "error reading cmdline file %s %s\n",
- cmdline_file, strerror(errno));
- XERROR(errno, "could not read process command line for pid %d\n",
- pid);
- } else {
- for (i = 0; i < sz; i++)
- if (cmdline[i] == 0)
- cmdline[i] = ' ';
- cmdline[sz] = 0;
- fprintf(out, "%s", cmdline);
- }
+ for (i = 0; i < sz; i++)
+ if (cmdline[i] == 0)
+ cmdline[i] = ' ';
+ cmdline[sz] = 0;
+ fprintf(out, "%s", cmdline);
+ }
+ if (sz == -1) {
+ DEBUG(1, "error reading cmdline file %s %s\n",
+ cmdline_file, strerror(errno));
+ fprintf(out, "(error reading process command line)");
}
fprintf(out, "\n");
close (fd);
|