Re: Changing argv[0] under Linux.

DervishD (raul@pleyades.net)
Wed, 15 Jan 2003 12:28:31 +0100


Hi Miquel :))

> >Last time I checked argv[0] was 512 bytes. Many daemons overwrite
> >it with no problem.
> No cigar. This stuff is all set up by the kernel on the stack;

Thanks a lot for your help :)) FYI, this question is related to
the virtual-console-only init clone that I wrote some time ago (I
used sysvinit for inspiration and good advice), I think I wrote you
about this. Anyway, you are in the acknowledgement list doubly, now
;))) I'm going to release this init in a week or so, after having
using it for more than a year at home without problems.

> If you want to modify argv[0] etc, loop over argv[], count howmuch
> space there is (strlen(argv[0] + 1 + strlen(argv[1] + 1 ... etc)
> and make sure you do NOT write a string longer than that. Also
> make sure that you end the string with a double \0

How about portability? Not that worries me, since this code will
go to a Linux-only program, just curiosity. Other OSes do the same
stack layout?

Raśl
-
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/