0

I have a BusyBox based system, and another one with vanilla Ubuntu LTS.

I made a C++ program which takes main()'s argv[1] as a command name, to fork() and execl() that command in the child process. Right before, I did dup2() to redirect the child's standard output, similar to this, so the parent process can read() its output. Then, the text read from the child is written to the console, with markers, to see that it was the parent who output this.

Now if I run this program with, as its arg, "dd --help", then two different things happen:

  • on the Ubuntu system, the output clearly comes from the parent process (and only)
  • on the BusyBox system, the parent process reads back nothing, and the output of dd writes directly to the console, apparently bypassing my (attempt at) redirection.

Since all the little commands on the BusyBox system are symlinks to the one BusyBox executable and I thought there could be a problem, I also tried making a child process out of "busybox dd --help". That changed nothing, though.

But: if I do "busybox --help", all of the output is caught by the child process and nothing "spilled besides" it. (note I left out the "sub command" dd here, only --help for BusyBox itself)

What's the reason for this happening, and (how) can I get this to work as intended, on the BusyBox system, too?

1 Answer 1

1

Busybox is outputting its own output, e.g. when calling it with options like --help, on stdout. But its implemented commands, like "dd", are output on stderr - even if it's not errors, which I found rather unintuitive and hence didn't look down that alley at first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.