diff options
author | Rob Landley <rob@landley.net> | 2006-01-29 06:45:38 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-01-29 06:45:38 +0000 |
commit | 03628c8f75bafd348cf32ea253279e6bc0596a90 (patch) | |
tree | 4478db7a7fe52ea0f600546cb0b4f2fe5507f15b /docs | |
parent | b1b3cee831bc8dfcf439ad69f4694d0a8ca3f7e9 (diff) | |
download | busybox-w32-03628c8f75bafd348cf32ea253279e6bc0596a90.tar.gz busybox-w32-03628c8f75bafd348cf32ea253279e6bc0596a90.tar.bz2 busybox-w32-03628c8f75bafd348cf32ea253279e6bc0596a90.zip |
Remind me to implement bb_fork_exec()...
Diffstat (limited to 'docs')
-rw-r--r-- | docs/busybox.net/programming.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/busybox.net/programming.html b/docs/busybox.net/programming.html index f77f3c3a6..6dbe6931f 100644 --- a/docs/busybox.net/programming.html +++ b/docs/busybox.net/programming.html | |||
@@ -235,6 +235,12 @@ second argument to pw_encrypt(text,buffer).</p> | |||
235 | 235 | ||
236 | <h2><a name="tips_vfork">Fork and vfork</a></h2> | 236 | <h2><a name="tips_vfork">Fork and vfork</a></h2> |
237 | 237 | ||
238 | <p>Busybox hides the difference between fork() and vfork() in | ||
239 | libbb/bb_fork_exec.c. If you ever want to fork and exec, use bb_fork_exec() | ||
240 | (which returns a pid and takes the same arguments as execve(), although in | ||
241 | this case envp can be NULL) and don't worry about it. This description is | ||
242 | here in case you want to know why that does what it does.</p> | ||
243 | |||
238 | <p>On systems that haven't got a Memory Management Unit, fork() is unreasonably | 244 | <p>On systems that haven't got a Memory Management Unit, fork() is unreasonably |
239 | expensive to implement, so a less capable function called vfork() is used | 245 | expensive to implement, so a less capable function called vfork() is used |
240 | instead.</p> | 246 | instead.</p> |
@@ -277,6 +283,11 @@ processes running at the same time. It means you can't have two processes | |||
277 | sharing the same memory without stomping all over each other. As soon as | 283 | sharing the same memory without stomping all over each other. As soon as |
278 | the child calls exec(), the parent resumes.</p> | 284 | the child calls exec(), the parent resumes.</p> |
279 | 285 | ||
286 | <p>If the child's attempt to call exec() fails, the child should call _exit() | ||
287 | rather than a normal exit(). This avoids any atexit() code that might confuse | ||
288 | the parent. (The parent should never call _exit(), only a vforked child that | ||
289 | failed to exec.)</p> | ||
290 | |||
280 | <p>(Now in theory, a nommu system could just copy the _stack_ when it forks | 291 | <p>(Now in theory, a nommu system could just copy the _stack_ when it forks |
281 | (which presumably is much shorter than the heap), and leave the heap shared. | 292 | (which presumably is much shorter than the heap), and leave the heap shared. |
282 | In practice, you've just wound up in a multi-threaded situation and you can't | 293 | In practice, you've just wound up in a multi-threaded situation and you can't |