aboutsummaryrefslogtreecommitdiff
path: root/docs/nofork_noexec.txt
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-01-06 06:27:17 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-01-06 06:27:17 +0000
commitbcd5fc12ec4d31f7633460cb66c2e8a5436ace18 (patch)
tree6664a87764ecf647c41520078d1328dca2dc7e75 /docs/nofork_noexec.txt
parent56ea65ca5f30778f05c8882b04e3a94c869bbca4 (diff)
downloadbusybox-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/nofork_noexec.txt')
-rw-r--r--docs/nofork_noexec.txt25
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
3Unix shells traditionally execute some commands internally in the attempt 3Unix shells traditionally execute some commands internally in the attempt
4to dramatically speed up execution. It will be slow as hell if for every 4to 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
6have to _reimplement_ these commands internally. 6have to _reimplement_ these commands internally.
7 7
8Busybox is unique in this regard because it already is a collection 8Busybox 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
11are exactly those applets which are eligible for these tricks. 11are exactly those applets which are eligible for these tricks.
12 12
13Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such 13Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such
14in applets.h. CONFIG_FEATURE_PREFER_APPLETS is a config option which 14in applets.h. FEATURE_PREFER_APPLETS is a config option which
15globally enables usage of NOFORK/NOEXEC tricks. 15globally enables usage of NOFORK/NOEXEC tricks.
16If it is enabled, FEATURE_SH_STANDALONE can be enabled too,
17and then shells will use NOFORK/NOEXEC tricks for ordinary commands.
18NB: shell builtins use these tricks regardless of FEATURE_SH_STANDALONE
19or FEATURE_PREFER_APPLETS.
16 20
17If you want to call a program and wait for it, use spawn_and_wait(argv). 21In C, if you want to call a program and wait for it, use
18It will check whether argv[0] is an applet name and will optionally 22spawn_and_wait(argv), BB_EXECVP(prog,argv) or BB_EXECLP(prog,argv0,...).
19do NOFORK/NOEXEC thing. 23They check whether program name is an applet name and optionally
24do NOFORK/NOEXEC thing depending on configuration.
20 25
21NOEXEC 26
27 NOEXEC
22 28
23NOEXEC applet should work correctly if another applet forks and then 29NOEXEC applet should work correctly if another applet forks and then
24executes exit(<applet>_main(argc,argv)) in the child. The rules 30executes exit(<applet>_main(argc,argv)) in the child. The rules
@@ -32,9 +38,10 @@ roughly are:
32* ... 38* ...
33 39
34NOEXEC applets save only one half of fork+exec overhead. 40NOEXEC applets save only one half of fork+exec overhead.
35NOEXEC trick is disabled for NOMMU compile. 41NOEXEC trick is disabled for NOMMU build.
42
36 43
37NOFORK 44 NOFORK
38 45
39NOFORK applet should work correctly if another applet simply runs 46NOFORK 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* ...