diff options
author | Herb Lewis <herb@samba.org> | 2004-05-01 00:45:15 +0000 |
---|---|---|
committer | Herb Lewis <herb@samba.org> | 2004-05-01 00:45:15 +0000 |
commit | 3b97687d0e1ca12e691bbe75be86ffdeabdb0818 (patch) | |
tree | 5971d4a02b2c302c25eeb156ea4f09879d2994d8 | |
parent | 332b78b2e9b2c8d69ef8d10ce9357c2464e01f2c (diff) | |
download | samba-3b97687d0e1ca12e691bbe75be86ffdeabdb0818.tar.gz |
r434: merge change 416 to trunk - add PID and newline to debuglevel messages
-rw-r--r-- | source/lib/debug.c | 7 | ||||
-rw-r--r-- | source/utils/smbcontrol.c | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/source/lib/debug.c b/source/lib/debug.c index 43789f8cf13..b0d8ff35230 100644 --- a/source/lib/debug.c +++ b/source/lib/debug.c @@ -209,8 +209,8 @@ static char *debug_list_class_names_and_levels(void) dim += l; } - /* create single string list */ - b = buf = malloc(dim); + /* create single string list - add space for newline */ + b = buf = malloc(dim+1); if (!buf) { err = True; goto done; @@ -220,7 +220,8 @@ static char *debug_list_class_names_and_levels(void) strncpy(b, list[i], l); b = b + l; } - b[-1] = '\0'; + b[-1] = '\n'; /* replace last space with newline */ + b[0] = '\0'; /* null terminate string */ done: /* free strings list */ diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c index 8a27684a4d3..2eb661c8b68 100644 --- a/source/utils/smbcontrol.c +++ b/source/utils/smbcontrol.c @@ -82,6 +82,14 @@ static void wait_replies(BOOL multiple_replies) } while (timeout - (time(NULL) - start_time) > 0); } +/* Message handler callback that displays the PID and a string on stdout */ + +static void print_pid_string_cb(int msg_type, pid_t pid, void *buf, size_t len) +{ + printf("PID %u: %.*s", (unsigned int)pid, (int)len, (const char *)buf); + num_replies++; +} + /* Message handler callback that displays a string on stdout */ static void print_string_cb(int msg_type, pid_t pid, void *buf, size_t len) @@ -281,7 +289,7 @@ static BOOL do_debuglevel(const pid_t pid, const int argc, const char **argv) if (!send_message(pid, MSG_REQ_DEBUGLEVEL, NULL, 0, False)) return False; - message_register(MSG_DEBUGLEVEL, print_string_cb); + message_register(MSG_DEBUGLEVEL, print_pid_string_cb); wait_replies(pid == 0); |