additional applets available as ash builtins?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sat Apr 12 22:33:11 UTC 2008


On Sat, 12 Apr 2008, Cristian Ionescu-Idbohrn wrote:

> On Sat, 12 Apr 2008, Denys Vlasenko wrote:
>
> > This patch should make it even faster by not forking for all NOFORK
> > applets.
> >
> > Can you give it a try?
>
> But of course.  Please give me until tomorrow.

Looks good for most of the applets I tested:

  basename, cat, chmod, dirname, echo, false, mkdir, rm, rmdir,
  seq, sleep, sync, test, touch, true, usleep

but I didn't touch these:

  awk, chgrp, chown, dd, find, hexdump, hostid, length, logname,
  pwd, sort, whoami, xargs, yes

and found these seem to fork:

'tac':

,----
| # strace -ff -tt -e trace=process ./busybox ash -c 'tac /tmp/f'
| 23:18:43.925096 execve("./busybox", ["./busybox", "ash", "-c", "tac
| /tmp/f"], [/* 55 vars */]) = 0
| 23:18:43.927729 clone(Process 13609 attached
| child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
| child_tidptr=0xb7df86f8) = 13609
| [pid 13608] 23:18:43.928099 waitpid(-1, Process 13608 suspended
| 2
| 1
|  <unfinished ...>
| [pid 13609] 23:18:43.928625 exit_group(0) = ?
| Process 13608 resumed
| Process 13609 detached
| 23:18:43.928767 <... waitpid resumed> [{WIFEXITED(s) && WEXITSTATUS(s) ==
| 0}], 0) = 13609
| 23:18:43.928807 --- SIGCHLD (Child exited) @ 0 (0) ---
| 23:18:43.928867 exit_group(0)           = ?
| Process 13608 detached
`----

cp:

,----
| # strace -ff -tt -e trace=process ./busybox ash -c 'cp /tmp/f /tmp/g'
| 23:59:03.642270 execve("./busybox", ["./busybox", "ash", "-c", "cp /tmp/f /tmp/g"], [/* 55 vars */]) = 0
| 23:59:03.645802 clone(Process 14085 attached
| child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7d776f8) = 14085
| [pid 14085] 23:59:03.647643 exit_group(0) = ?
| Process 14085 detached
| 23:59:03.648324 --- SIGCHLD (Child exited) @ 0 (0) ---
| 23:59:03.648679 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 14085
| 23:59:03.649179 exit_group(0)           = ?
| Process 14084 detached
`----

cut:

,----
| # strace -ff -tt -e trace=process ./busybox ash -c 'cut -d: -f1 < /tmp/foo'
| 00:05:59.102011 execve("./busybox", ["./busybox", "ash", "-c", "cut -d: -f1 < /tmp/foo"], [/* 55 vars */]) = 0
| 00:05:59.105521 clone(Process 18307 attached
| child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7d936f8) = 18307
| 1
| a
| [pid 18307] 00:05:59.107510 exit_group(0) = ?
| Process 18307 detached
| 00:05:59.108127 --- SIGCHLD (Child exited) @ 0 (0) ---
| 00:05:59.108472 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 18307
| 00:05:59.108993 exit_group(0)           = ?
| Process 18306 detached
`----

ls:

,----
| # strace -ff -tt -e trace=process ./busybox ash -c 'ls /tmp/foo /tmp/bar'
| 00:16:36.751571 execve("./busybox", ["./busybox", "ash", "-c", "ls /tmp/foo /tmp/bar"], [/* 55 vars */]) = 0
| 00:16:36.754260 clone(Process 18427 attached
| child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7e1d6f8) = 18427
| [pid 18426] 00:16:36.755279 waitpid(-1, Process 18426 suspended
| /tmp/bar  /tmp/foo
|  <unfinished ...>
| [pid 18427] 00:16:36.755759 exit_group(0) = ?
| Process 18426 resumed
| Process 18427 detached
| 00:16:36.755905 <... waitpid resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 18427
| 00:16:36.755945 --- SIGCHLD (Child exited) @ 0 (0) ---
| 00:16:36.756007 exit_group(0)           = ?
| Process 18426 detached
`----


Cheers,

-- 
Cristian



More information about the busybox mailing list