ps output redirection problem [BUG, SOLVED]
Ignacio García Pérez
iggarpe at terra.es
Wed Mar 28 06:43:44 PDT 2007
Luciano Miguel Ferreira Rocha escribió:
Ok. Mistery solved:
Have a look at the last line of format_process in procps/ps.c:
printf("%.*s\n", terminal_width, buffer);
The terminal_width variable gets initialized to INT_MAX when there is no
terminal (which is the case when we are redirecting the output), and
*for some reason, printf does not line such a huge value !!!*
I've verified that using 1000 instead of INT_MAX *solves the problem*,
but doesn't look like a good solution. Perhaps the ps.c code maintainer
could come up with a better solution.
> On Wed, Mar 28, 2007 at 12:22:30PM +0200, Ignacio García Pérez wrote:
>
>> Luciano Miguel Ferreira Rocha escribió:
>>
>>> On Wed, Mar 28, 2007 at 11:58:05AM +0200, Ignacio García Pérez wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> I just noticed that
>>>>
>>>> ps > out.txt
>>>>
>>>> ps 2>&1 > out.txt
>>>>
>>>> Produce an empty out.txt file. If no output redirection is used, the
>>>> output of the ps command is as expected.
>>>>
>>>> Any idea of what's wrong?
>>>>
>>>>
>>> Are you using busybox statically linked to glibc?
>>>
>>>
>>>
>> I'm using busybox 1.4.2 dynamically linked to glibc.
>>
>
> That clears glibc. What shell are you using?
>
> And could you please reply also to the list, to keep the discussion
> there?
>
>
More information about the busybox
mailing list