diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/nofork_noexec.txt | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/docs/nofork_noexec.txt b/docs/nofork_noexec.txt index c58f5a83f..2fb184a03 100644 --- a/docs/nofork_noexec.txt +++ b/docs/nofork_noexec.txt | |||
| @@ -33,6 +33,7 @@ roughly are: | |||
| 33 | * do not expect shared global variables/buffers to be in their | 33 | * do not expect shared global variables/buffers to be in their |
| 34 | "initialized" state. Examples: xfunc_error_retval can be != 1, | 34 | "initialized" state. Examples: xfunc_error_retval can be != 1, |
| 35 | bb_common_bufsiz1 can be scribbled over, ... | 35 | bb_common_bufsiz1 can be scribbled over, ... |
| 36 | (although usually xfunc_error_retval's state is not a problem). | ||
| 36 | * do not expect that stdio wasn't used before. Calling set[v]buf() | 37 | * do not expect that stdio wasn't used before. Calling set[v]buf() |
| 37 | can be disastrous. | 38 | can be disastrous. |
| 38 | * ... | 39 | * ... |
| @@ -81,18 +82,37 @@ are probably not worth the effort. | |||
| 81 | Any NOFORK applet is also a NOEXEC applet. | 82 | Any NOFORK applet is also a NOEXEC applet. |
| 82 | 83 | ||
| 83 | 84 | ||
| 85 | Calling NOFORK applets | ||
| 86 | |||
| 87 | API to call NOFORK applets is two functions: | ||
| 88 | |||
| 89 | run_nofork_applet(appno, argv) | ||
| 90 | spawn_and_wait(argv) // only if FEATURE_PREFER_APPLETS=y | ||
| 91 | |||
| 92 | First one is directly used by shells if FEATURE_SH_NOFORK=y. | ||
| 93 | Second one is used by many applets, but main users are xargs and find. | ||
| 94 | It itself calls run_nofork_applet(), if argv[0] turned out to be a name | ||
| 95 | of a NOFORK applet. | ||
| 96 | |||
| 97 | run_nofork_applet() saves/inits/restores option parsing, xfunc_error_retval, | ||
| 98 | applet_name. Thus, for example, caller does not need to worry about | ||
| 99 | option_mask32 getting trashed. | ||
| 100 | |||
| 101 | |||
| 84 | Relevant CONFIG options | 102 | Relevant CONFIG options |
| 85 | 103 | ||
| 86 | FEATURE_PREFER_APPLETS | 104 | FEATURE_PREFER_APPLETS |
| 87 | BB_EXECVP(cmd, argv) will try to exec /proc/self/exe | 105 | BB_EXECVP(cmd, argv) will try to exec /proc/self/exe |
| 88 | if command's name matches some applet name | 106 | if command's name matches some applet name; |
| 89 | applet tables will contain NOFORK/NOEXEC bits | ||
| 90 | spawn_and_wait(argv) will do NOFORK/NOEXEC tricks | 107 | spawn_and_wait(argv) will do NOFORK/NOEXEC tricks |
| 91 | 108 | ||
| 92 | FEATURE_SH_STANDALONE (needs FEATURE_PREFER_APPLETS=y) | 109 | //TODO: the above two things probably should have separate options? |
| 110 | |||
| 111 | FEATURE_SH_STANDALONE | ||
| 93 | shells will try to exec /proc/self/exe if command's name matches | 112 | shells will try to exec /proc/self/exe if command's name matches |
| 94 | some applet name | 113 | some applet name; shells will do NOEXEC trick on NOEXEC applets |
| 95 | shells will do NOEXEC trick on NOEXEC applets | 114 | |
| 115 | //TODO: split (same as for PREFER_APPLETS) | ||
| 96 | 116 | ||
| 97 | FEATURE_SH_NOFORK (needs FEATURE_PREFER_APPLETS=y) | 117 | FEATURE_SH_NOFORK |
| 98 | shells will do NOFORK trick on NOFORK applets | 118 | shells will do NOFORK trick on NOFORK applets |
