[lkml]   [2003]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Changing argv[0] under Linux.
On Tue, 14 Jan 2003, DervishD wrote:

> > > libc, but I think that is more on the kernel side, that's why I ask
> > Last time I checked argv[0] was 512 bytes. Many daemons overwrite
> > it with no problem.
> Any header where I can see the length for argv[0] or is this some
> kind of unoficial standard? Just doing strcpy seems dangerous to me
> (you can read 'paranoid'...).

The method used in INN is to make arg 1 some space. So
nnrpd -s' ' -D ...
You can check that argv[1] is -s, and what its length is, then happily
write over argv[0]. That's portable in practical terms, since most C
implementations just have the variable length args in sequence, while a
few have a fixed length array for args. You're safe in either case.

if (strncmp(argv[1], "-s", 2) && strlen(argv[1]) > REPLACELEN) {
sprintf(argv[0], "format", atuff...);

Some systems have setproctitle() but it doesn't appear to be posix.

bill davidsen <>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

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.080 / U:1.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site