diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-01-06 06:27:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-01-06 06:27:17 +0000 |
commit | bcd5fc12ec4d31f7633460cb66c2e8a5436ace18 (patch) | |
tree | 6664a87764ecf647c41520078d1328dca2dc7e75 /docs | |
parent | 56ea65ca5f30778f05c8882b04e3a94c869bbca4 (diff) | |
download | busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.tar.gz busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.tar.bz2 busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.zip |
tac: new applet. ~240 bytes.
Copyright (C) 2003 Yang Xiaopeng <yxp at hanwang.com.cn>
Copyright (C) 2007 Natanael Copa <natanael.copa@gmail.com>
Copyright (C) 2007 Tito Ragusa <farmatito@tiscali.it>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/nofork_noexec.txt | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/docs/nofork_noexec.txt b/docs/nofork_noexec.txt index d4abdf452..06c789aff 100644 --- a/docs/nofork_noexec.txt +++ b/docs/nofork_noexec.txt | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | Unix shells traditionally execute some commands internally in the attempt | 3 | Unix shells traditionally execute some commands internally in the attempt |
4 | to dramatically speed up execution. It will be slow as hell if for every | 4 | to dramatically speed up execution. It will be slow as hell if for every |
5 | "echo blah" shell will fork and exec /bin/echo. For this end, shells | 5 | "echo blah" shell will fork and exec /bin/echo. To this end, shells |
6 | have to _reimplement_ these commands internally. | 6 | have to _reimplement_ these commands internally. |
7 | 7 | ||
8 | Busybox is unique in this regard because it already is a collection | 8 | Busybox is unique in this regard because it already is a collection |
@@ -11,14 +11,20 @@ for speeding up busybox shells, and more. NOEXEC and NOFORK applets | |||
11 | are exactly those applets which are eligible for these tricks. | 11 | are exactly those applets which are eligible for these tricks. |
12 | 12 | ||
13 | Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such | 13 | Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such |
14 | in applets.h. CONFIG_FEATURE_PREFER_APPLETS is a config option which | 14 | in applets.h. FEATURE_PREFER_APPLETS is a config option which |
15 | globally enables usage of NOFORK/NOEXEC tricks. | 15 | globally enables usage of NOFORK/NOEXEC tricks. |
16 | If it is enabled, FEATURE_SH_STANDALONE can be enabled too, | ||
17 | and then shells will use NOFORK/NOEXEC tricks for ordinary commands. | ||
18 | NB: shell builtins use these tricks regardless of FEATURE_SH_STANDALONE | ||
19 | or FEATURE_PREFER_APPLETS. | ||
16 | 20 | ||
17 | If you want to call a program and wait for it, use spawn_and_wait(argv). | 21 | In C, if you want to call a program and wait for it, use |
18 | It will check whether argv[0] is an applet name and will optionally | 22 | spawn_and_wait(argv), BB_EXECVP(prog,argv) or BB_EXECLP(prog,argv0,...). |
19 | do NOFORK/NOEXEC thing. | 23 | They check whether program name is an applet name and optionally |
24 | do NOFORK/NOEXEC thing depending on configuration. | ||
20 | 25 | ||
21 | NOEXEC | 26 | |
27 | NOEXEC | ||
22 | 28 | ||
23 | NOEXEC applet should work correctly if another applet forks and then | 29 | NOEXEC applet should work correctly if another applet forks and then |
24 | executes exit(<applet>_main(argc,argv)) in the child. The rules | 30 | executes exit(<applet>_main(argc,argv)) in the child. The rules |
@@ -32,9 +38,10 @@ roughly are: | |||
32 | * ... | 38 | * ... |
33 | 39 | ||
34 | NOEXEC applets save only one half of fork+exec overhead. | 40 | NOEXEC applets save only one half of fork+exec overhead. |
35 | NOEXEC trick is disabled for NOMMU compile. | 41 | NOEXEC trick is disabled for NOMMU build. |
42 | |||
36 | 43 | ||
37 | NOFORK | 44 | NOFORK |
38 | 45 | ||
39 | NOFORK applet should work correctly if another applet simply runs | 46 | NOFORK applet should work correctly if another applet simply runs |
40 | <applet>_main(argc,argv) and then continues with its business (xargs, | 47 | <applet>_main(argc,argv) and then continues with its business (xargs, |
@@ -55,6 +62,8 @@ on what applet can/cannot do: | |||
55 | * if you allocate memory, you can use xmalloc() only on the very first | 62 | * if you allocate memory, you can use xmalloc() only on the very first |
56 | allocation. All other allocations should use malloc[_or_warn](). | 63 | allocation. All other allocations should use malloc[_or_warn](). |
57 | After first allocation, you cannot use any xfuncs. | 64 | After first allocation, you cannot use any xfuncs. |
65 | Otherwise, failing xfunc will return to caller applet | ||
66 | without freeing malloced data! | ||
58 | * All allocated data, opened files, signal handlers, termios settings, | 67 | * All allocated data, opened files, signal handlers, termios settings, |
59 | O_NONBLOCK flags etc should be freed/closed/restored prior to return. | 68 | O_NONBLOCK flags etc should be freed/closed/restored prior to return. |
60 | * ... | 69 | * ... |