[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Threads
Here is another dirty hack of a question to ask. Is it possible to change
the name of a running thread, and if so how? Here are some options:
- screwing with argv[0]
this will change the name of your program as reported by ps, at least on
my system. However if your program has multiple threads, all of them will
be shown as having the new name, as the process data is shared between
them all. So changing argv[0] just before creating a new thread or
anything like that will not work. Unless there is some funky way of
forcing it not to share this particular piece of data...
- screwing with /proc, somehow
should be possible to mess with your /proc/*/cmdline, but I'm not quite
sure whether it is. Anyone tried this? I believe this is where top looks
to determine process names, as it is not fooled by the argv[0] trick
mentioned above.
Why do I want to do this? 'cos it would be useful, when debugging, to see
which threads are currently active with ps, and see which one has gone
rogue and is sucking down 99.9% of cpu time using top :)
Michael