> I believe, this won't work under Linux. I'm not 100% sure about it but from
> what I can remember Linux pass a copy of the original argv to the program
> and changing it doesn't change the argv strings shown by ps. You must zap
> the strings itself inside the page allocated for argv.
> I would suggest the following code which works fine also under linux, even
> with zero args.
>
> #ifdef linux
> progname = argv[0];
> /* Fill the argv buffer vith 0's, once during the initialization */
> for (i=0; i<argc; argc++) {
> memset(argv[i], 0, strlen(argv[i]));
> }
> #endif
This is OK. It will work.
>
> /* Build status info */
> sprintf(status, "%s ...", ...);
> #ifdef bsdi
> argv[1] = status;
> #endif
> #ifdef linux
> /* Print the original argv[0] + status info in the argv buffer */
> sprintf(argv[0], "%s %s", progname, status);
> #endif
This may not work. The problem is that there is no guarantee that there
enough string space in argv[0] to hold the new string value. That is
why sendmail actually re-allocates/moves the argv[] strings to make
room, but such code is very ugly.
We can perform some tricks to make argv[0] larger by re-exec'ing the
postmaster, which we already do to make sure we have enough args, but
let's see what Linux people report.
> I would also suggest using only lowercase messages if possible. They don't
> hurt the eyes too much.
Yes, that would be nice, but I want to assign fixed string constants, so
they don't change, and currently I use the same strings that are
displayed as part of psql:
test=> update test set x=2;
UPDATE 2
^^^^^^
Didn't seem worth making another string for every command type, and
because it is a string constant, I can't lowercase it.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)