From 0e95769b435d1e21859efce6c1687e4343090ffc Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 25 Jun 2009 15:58:33 +0000 Subject: [PATCH] Call setproctitle earlier in the client, and include the socket name. Makes it easier to match client to server in ps/pgrep when using several servers. --- client.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index 9531286e..7969e6af 100644 --- a/client.c +++ b/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.48 2009-05-13 23:27:00 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.2 2009/06/05 07:15:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -46,6 +46,15 @@ client_init(char *path, struct client_ctx *cctx, int start_server, int flags) int mode; struct buffer *b; char *name; +#ifdef HAVE_SETPROCTITLE + char rpathbuf[MAXPATHLEN]; +#endif + +#ifdef HAVE_SETPROCTITLE + if (realpath(path, rpathbuf) == NULL) + strlcpy(rpathbuf, path, sizeof rpathbuf); + setproctitle("client (%s)", rpathbuf); +#endif if (lstat(path, &sb) != 0) { if (start_server && errno == ENOENT) { @@ -135,9 +144,6 @@ client_main(struct client_ctx *cctx) siginit(); logfile("client"); -#ifdef HAVE_SETPROCTITLE - setproctitle("client"); -#endif error = NULL; xtimeout = INFTIM;