From: Ernst B. <e.b...@xe...> - 2006-09-13 15:53:50
|
On Wednesday 13 September 2006 17:04, Michael Reinelt wrote: > Hi Ernst, > > > Here a little patch that changes the argv[0] of threads started with > > lcd4linux's thread.c to the thread name. > > Fine, good idea! > > Did you already commit? Did I give you CVS write access? Nope, doesn't seem like I have CVS write access. (I'm also not listed on the SF.net developer list for lcd4linux) > > a few more patches to the thread functions will follow shortly, I'm > > implementing some stuff for my "VFD4Linux" driver and will send patches > > for the generic parts I need during the progress. > > Patches are always welcome! > > > info("thread %s starting...", name); > > + if (thread_argc > 0) { > > + strncpy(thread_argv[0],name,strlen(thread_argv[0])); > > + } > > just curious: isn't there a problem if the new (thread) name is longer > than the "original" name, so your strncpy would overwrite things that > are better not overwritten? I thing I read something like this sometime > somewhere..... Thats why I used "strNcpy" with the original argv[0] length as limit. It won't overwrite data it shouldn't, but will truncate the threads name if its longer than the original binary name. To get longer names, one would have to do lots strange stuff, like reorganizing the layout of the entire argv array and possible the environment variables... too much work for a little cosmetic trick. Simply malloc'ing a new string and linking it into argv[0] unfortunately doesn't work. > > bye, Michael Greetings, /Ernst |