Redirection of stdout for commands

sleepy_dog at gmx.de sleepy_dog at gmx.de
Fri Oct 8 15:02:59 UTC 2021



Denys Vlasenko wrote:
 > [busybox] dd --help prints to stderr.

D'oh! Lol, thanks!
Any particular reason for this choice? It seems unintuitive to me to put
normal output on an error stream, I guess separation of busybox itself
and commands was wanted for some reason?



> On Fri, Oct 8, 2021 at 4:15 PM <sleepy_dog at gmx.de> wrote:
>> Hello there,
>>
>> 1st time post here.
>>
>> On a BusyBox based system (image built recently) I have a program
>> calling external executables and reading their text output.
>> This is done with fork, execl, and beforehand, redirecting the output
>> with dup2, quite like here:
>> https://dzone.com/articles/simple-popen2-implementation
>>
>> This generally works. There is one oddity, when calling Linux commands
>> with this method:
>>
>> Depending on whether I run that same program on a regular distribution
>> Linux machine, or on BusyBox, I get different results.
>> It works as expected on e.g. Ubuntu.
>> On BusyBox, it's different:
>> - if I call only BusyBox with "busybox --help", rhings work as expected,
>> e.g. nothing spills to the console, and I read all the input vie my
>> redirected stdout
> busybox --help prints to stdout.
>
>> - if I call a command handle by busybox, e.g. "dd --help", I get back
>> nothing from stdout, and all text output spills directly on the console
>> - if I call busybox explicitly, with the command added, like "busybox dd
>> --help", it's the same as previous, i.e. doesn't work
> [busybox] dd --help prints to stderr.
>



More information about the busybox mailing list