[systemd-devel] [patch] job: print colored status message at the right spot

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Dec 21 13:43:28 PST 2011


On 12/21/2011 07:46 PM, Jan Engelhardt wrote:
>
> On Wednesday 2011-12-21 15:08, Zbigniew Jędrzejewski-Szmek wrote:
>> On 12/21/2011 02:23 PM, Jan Engelhardt wrote:
>>> +unsigned int console_width(void)
>>> +{
>>>   ...
>>> +}
>>> +
>>
>> Hi,
>> there already is columns() in src/util.c :)
>
> It gets the #columns from stdout rather than /dev/console to
> which the status string is to be written, and keeps the value around
> forever without updating even if stdout changes its terminal size.
I guess that in case of columns(), this is reasonable: it is used in
short lived programs like systemctl and loginctl which print a table of 
data in one go.

Nevertheless, columns() and console_width() implementations are similar, 
but slightly different. Maybe columns() should become a
wrapper which does the caching and then calls a new function with a 'fd' 
parameter.

> Speaking of which, SIGWINCH is abused in that regard...
I think that using SIGWINCH for alt-up is a behaviour dictated by the 
kernel.

Best,
Zbyszek


More information about the systemd-devel mailing list