[lkml]   [2003]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Changing argv[0] under Linux.
"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 <stdio.h>
#include <string.h>
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);
return 0;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.112 / U:2.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site