tags:

views:

56

answers:

2

Is busybox available in shared library form? I would like to use individual apps programmatically instead of using system(). I've heard about libbusybox and libbb but could not find any documentation.

+1  A: 

If such a library existed for busybox, it would probably call fork or system anyway, so there is no real difference.

Delan Azabani
Of course it wouldn't need to call `fork`. Want a list of files that would usually been obtained by calling `grep`? Call the function that implements `grep` functionality in BusyBox. No fork.
Pascal Cuoq
Yes... but... that would only work if the program you are trying to use has dev headers so that you can call its internal functions. Otherwise, for binary-only applications, you're stuck with calling them externally.
Delan Azabani
The problem is that it would probably call `exit(x)` without returning to the psudo_main function, and then your probram would be dead.
nategoose
A: 

If you are on a tiny embedded system where it matters, you can link your own app into the busybox binary, then you can call its functions without any dynamic linker at all.

If you are not, just use system(), or some fork/exec combo.

It is unlikely you'll want to call the utilities so often that performance matters.

MarkR