> >> the data is still truncated and partial.. and you keep running with it. > > which is not that big deal. I agree, that this is not 100% handy. > but suppose there is a process with very long name. long enough to cause > overrun and powertop abort(). and that process is part of a runtime and > it must be alive, etc... and that automatically leaves only one option -- > either that process or powertop. and never together. > for cases where you know you can truncate correctly, making a "truncate_string_to(str, n, trailing_pattern)" helper that you call explicitly is likely a better answer than hiding it inside a sprintf-like makro. (and you then truncate the source string/content) but maybe I'm just getting old and grumpy ;-) also asprintf() for cases where you don't know how long it will be is not a bad idea