additional applets available as ash builtins?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Apr 13 10:08:31 UTC 2008


On Sun, 13 Apr 2008, Denys Vlasenko wrote:

> > > From your list above, kill is already a builtin,
> >
> > Hmm... I don't see it.  include/applets.h says:
> >
> >   USE_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_NEVER))
> >
> > meaning kill isn't a NOFORK/NOEXEC applet?
>
> Yes, it isn't. It can probably made to be one.

Of course.

> As I said, there were no focused campaign to make more applets
> NOFORK/NOEXEC.

As I see it, that would be one way to make ash faster than dash,
don't you think?  I'm in bad need of a small and fast shell ;-)

> (hint: you can do it)

I know ;-)

> However, in ash "kill" is indeed handled specially (as a builtin),
> mostly because it has to support "kill %JOBNUM":

Yes, I've seen that.  But not being obvious:

,----
| # egrep 'return.*_main' shell/ash.c | egrep -v ash_main
|         return kill_main(argc, argv);
|         return echo_main(argc, argv);
|         return test_main(argc, argv);
`----

,----
| # egrep '^USE_(KILL|ECHO|TEST)\(' include/applets.h
| USE_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
| USE_TEST(APPLET_NOUSAGE([[, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
| USE_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_NEVER, echo))
| USE_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_NEVER))
| USE_TEST(APPLET_NOEXEC(test, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
`----

confused me :(  And now it's test that's confusing me :(

,----
| # egrep '^USE_TEST\(' include/applets.h
| USE_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
| USE_TEST(APPLET_NOUSAGE([[, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
| USE_TEST(APPLET_NOEXEC(test, test, _BB_DIR_USR_BIN, _BB_SUID_NEVER, test))
`----

Could you please explain why the difference?

[	-> NOFORK
test	-> NOEXEC

Please consider this too:

,----
| # ./busybox --help
| BusyBox v1.11.0.svn (2008-04-12 22:37:00 CEST) multi-call binary
| Currently defined functions:
`----
        [, [[, adjtimex, arp, arping, ash, basename, bbconfig, brctl,

Is '[[' out of the game?

,----
| # ./busybox ash -c '[[ $i -eq 0 ]] || echo x'
| ash: 0: unknown operand
| x
| # ./busybox ash -c '[ $i -eq 0 ] || echo x'
| ash: 0: unknown operand
| x
`----

> > could be NO(EXEC|FORK) candidates.
>
> Exactly. Also we'll need to review where in shell we can avoid not only
> exec()ing, but fork()ing too. IOW: shells to date were not using
> NOFORKiness of some applets to full extent.

Right.


Cheers,

-- 
Cristian



More information about the busybox mailing list