From 1160d92960d0b3c12dc9a7a8bd6444f5aca809c5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 10 Nov 2022 15:02:23 +0300 Subject: [PATCH] Stats in process title --- CHANGES | 1 + dht-bootstrap.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index d54f227..69f5564 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ * select() replaced with poll() * arc4random instead of /dev/urandom reading * Some simple hardening + * Keep statistics in process title (BSD) 20 November 2011: dht-bootstrap-0.2 diff --git a/dht-bootstrap.c b/dht-bootstrap.c index e8c0b2c..07ac332 100644 --- a/dht-bootstrap.c +++ b/dht-bootstrap.c @@ -37,6 +37,12 @@ THE SOFTWARE. #define MIN(x, y) ((x) <= (y) ? (x) : (y)) +#ifdef __linux__ +// clang-format off +void setproctitle_fast(const char *_fmt, ...) {} +// clang-format on +#endif + static int send_ping(struct sockaddr *sa, int salen, const unsigned char *tid, int tid_len); static int @@ -507,13 +513,12 @@ main(int argc, char **argv) tv_sec = random() % 30; int tv_msec = random() % 1000; - if (dht_debug) - debugf( - "%d+%d %d+%d\n", - list_elements(&v4_confirmed), - list_elements(&v6_confirmed), - list_elements(&v4_new), - list_elements(&v6_new)); + setproctitle_fast( + "%d+%d %d+%d", + list_elements(&v4_confirmed), + list_elements(&v6_confirmed), + list_elements(&v4_new), + list_elements(&v6_new)); rc = poll(fds, 2, tv_sec * 1000 + tv_msec); if (rc < 0) { -- 2.44.0