Received: from [140.186.70.92] (port=39917 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFCBT-00023E-Dn for qemu-devel@nongnu.org; Sun, 07 Nov 2010 15:49:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFCBC-0006WY-Gi for qemu-devel@nongnu.org; Sun, 07 Nov 2010 15:49:35 -0500 Received: from mailout-de.gmx.net ([213.165.64.22]:42384 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PFCBC-0006WH-2c for qemu-devel@nongnu.org; Sun, 07 Nov 2010 15:49:34 -0500 From: Torsten =?iso-8859-1?q?F=F6rtsch?= Subject: Re: [Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit. Date: Sun, 7 Nov 2010 21:49:27 +0100 References: <1289144652-23463-1-git-send-email-jwm@horde.net> In-Reply-To: <1289144652-23463-1-git-send-email-jwm@horde.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201011072149.28266.torsten.foertsch@gmx.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: John Morrissey Hi, On Sunday, November 07, 2010 16:44:12 John Morrissey wrote: > - if (prctl(PR_SET_NAME, name)) { > - perror("unable to change process name"); > - exit(1); > - } > + > + last_argv_byte =3D argv[argc - 1] + strlen(argv[argc - 1]); > + > + len =3D snprintf(argv[0], last_argv_byte - argv[0], "%s", name); > + > + p =3D &argv[0][len]; > + while (p <=3D last_argv_byte) > + *p++ =3D '\0'; > + for (i =3D 1; i < argc; ++i) > + argv[i] =3D (char *) ""; I am quite new to the list but why not do both call prctl(PR_SET_NAME, name= )=20 and overwrite argv? The point is some tools read /proc/PID/cmdline but others the name field in= =20 /proc/PID/status. The former is changed by overwriting argv the latter by=20 prctl. Torsten F=F6rtsch =2D-=20 Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net