Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 14 Jan 2003 15:17:20 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 14 Jan 2003 15:17:20 -0500 Received: from tantale.fifi.org ([216.27.190.146]:14745 "EHLO tantale.fifi.org") by vger.kernel.org with ESMTP id ; Tue, 14 Jan 2003 15:17:19 -0500 To: root@chaos.analogic.com Cc: DervishD , Linux-kernel Subject: Re: Changing argv[0] under Linux. References: Mail-Copies-To: nobody From: Philippe Troin Date: 14 Jan 2003 12:25:54 -0800 In-Reply-To: Message-ID: <87iswrzdf1.fsf@ceramic.fifi.org> Lines: 36 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org "Richard B. Johnson" writes: > On Tue, 14 Jan 2003, DervishD wrote: > > > Hi all :)) > > > > I'm not sure whether this issue belongs to the kernel or to the > > libc, but I think that is more on the kernel side, that's why I ask > > here. > > > > Last time I checked argv[0] was 512 bytes. Many daemons overwrite > it with no problem. Last time must have been in an alternate reality. You just overwrote all your arguments (argv[0] and others) and part of the environment. Try this for a change: #include #include extern char ** _environ; int main(int cnt, char *argv[]) { char **eptr; for ( eptr = _environ; *eptr; ++eptr ) printf("ENV before: %s\n", *eptr); strcpy(argv[0], "How-long-do-you-want-this-string-to-be?--is-this-long-enough?"); for ( eptr = _environ; *eptr; ++eptr ) printf("ENV after: %s\n", *eptr); pause(); return 0; } Phil. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/