aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergeRon Yorston2016-04-041-2/+1
|\
| * applet_tables: save space by removing applet name offsetsRon Yorston2016-03-301-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array applet_nameofs consumes two bytes per applet. It encodes nofork/noexec flags suid flags the offset of the applet name in the applet_name string Change the applet_table build tool to store the flags in two separate arrays (applet_flags and applet_suid). Replace applet_nameofs[] with a smaller version that only stores a limited number of offsets. This requires changes to the macros APPLET_IS_NOFORK, APPLET_IS_NOEXEC and APPLET_SUID. According to Valgrind the original find_applet_by_name required 353 cycles per call, averaged over all names. Adjusting the number of known offsets allows space to be traded off against execution time: KNOWN_OFFSETS cycles bytes (wrt KNOWN_OFFSETS = 0) 0 9057 - 2 4604 32 4 2407 75 8 1342 98 16 908 130 32 884 194 This patch uses KNOWN_OFFSETS = 8. v2: Remove some dead code from the applet_table tool; Treat the applet in the middle of the table as a special case. v3: Use the middle applet to adjust the start of the linear search as well as the last applet found. v4: Use an augmented linear search in find_applet_by_name. Drop the special treatment of the middle name from get_applet_name: most of the advantage now derives from the last stored value. v5: Don't store index in applet_nameofs, it can be calculated. v6: Tweaks by Denys function old new delta find_applet_by_name 25 125 +100 applet_suid - 92 +92 run_applet_no_and_exit 452 460 +8 run_applet_and_exit 695 697 +2 applet_name_compare 31 - -31 applet_nameofs 734 14 -720 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 3/1 up/down: 202/-751) Total: -549 bytes text data bss dec hex filename 925464 906 17160 943530 e65aa busybox_old 924915 906 17160 942981 e6385 busybox_unstripped Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2015-10-131-14/+25
|\|
| * remove global "jmp_buf die_jmp" from !FEATURE_PREFER_APPLETS buildsDenys Vlasenko2015-10-091-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta xfunc_has_died - 21 +21 sleep_much - 12 +12 sleep10 - 9 +9 die_func - 4 +4 fflush_stdout_and_exit 35 36 +1 builtin_type 121 119 -2 die_sleep 4 - -4 xfunc_die 60 24 -36 hush_main 1128 1011 -117 die_jmp 156 - -156 ------------------------------------------------------------------------------ (add/remove: 4/2 grow/shrink: 1/3 up/down: 47/-315) Total: -268 bytes text data bss dec hex filename 939992 992 17652 958636 ea0ac busybox_old 939880 992 17496 958368 e9fa0 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | mingw: define a macro for spawnRon Yorston2015-05-271-3/+2
| |
* | Merge branch 'busybox' into mergeRon Yorston2012-03-231-1/+9
|\| | | | | | | | | Conflicts: Makefile.flags
| * bb_daemonize_or_rexec(): add flag to double-fork; use it in start-stop-daemonPeter Korsgaard2011-11-091-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Add a DAEMON_DOUBLE_FORK flag to make bb_daemonize double-fork so it isn't a session leader, and hence doesn't get a controlling tty on Linux if a tty is ever opened, similar to how libdaemon's daemon_fork or the big start-stop-daemon does it - And use it in start-stop-daemon. For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3 Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge commit 'da4441c44f6efccb6f7b7588404d9c6bfb7b6af8' into mergeRon Yorston2012-03-221-35/+26
|\| | | | | | | | | | | | | Conflicts: libbb/vfork_daemon_rexec.c networking/wget.c procps/ps.c
| * libbb: spawn should remove child which failed to execDenys Vlasenko2011-02-031-0/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * move nofork_save_area from libbb.h to vfork_daemon_rexec.cDenys Vlasenko2011-02-021-29/+19
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: make BB_EXECVP/LP try to exec real binary if there's no /proc/self/exeDenys Vlasenko2011-02-021-6/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'origin/master' (early part)Nguyễn Thái Ngọc Duy2010-09-141-1/+1
|\|
| * *: make GNU licensing statement forms more regularDenys Vlasenko2010-08-161-1/+1
| | | | | | | | | | | | | | This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'origin/master' (early part)Nguyễn Thái Ngọc Duy2010-09-141-50/+2
|\|
| * *: introduce and use xfork() and xvfork()Pascal Bellard2010-07-041-15/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta launch_helper 170 169 -1 setup_heredoc 312 302 -10 handle_dir_common 367 354 -13 expand_vars_to_list 2456 2443 -13 open_transformer 89 74 -15 data_extract_to_command 439 423 -16 do_ipaddr 1406 1389 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-85) Total: -85 bytes Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: introduce and use BB_EXECVP_or_die()Pascal Bellard2010-07-041-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta BB_EXECVP_or_die - 47 +47 time_main 1042 1043 +1 chrt_main 371 364 -7 ionice_main 292 282 -10 setsid_main 69 56 -13 nohup_main 236 223 -13 cttyhack_main 266 253 -13 chroot_main 94 81 -13 chpst_main 746 733 -13 timeout_main 297 279 -18 taskset_main 541 522 -19 vfork_child 67 45 -22 parse 975 953 -22 lpd_main 770 748 -22 launch_helper 192 170 -22 tcpudpsvd_main 1810 1782 -28 nice_main 190 156 -34 env_main 242 206 -36 run_command 221 174 -47 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/17 up/down: 48/-352) Total: -304 bytes Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: make exec failure message more consistentDenys Vlasenko2010-06-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: Replace spawn() and spawn_and_wait() with Win32 versionNguyễn Thái Ngọc Duy2010-09-101-1/+4
|/
* *: code shrink and better "died from signal" reporting from wait4pidDenys Vlasenko2010-03-181-1/+1
| | | | | | | | | | | | | | function old new delta parse 964 967 +3 udhcp_run_script 670 665 -5 singlemount 911 906 -5 mount_it_now 360 355 -5 inotifyd_main 521 516 -5 xspawn 21 - -21 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/4 up/down: 3/-41) Total: -38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: introduce and use ffulsh_all()Denys Vlasenko2009-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | function old new delta buffer_fill_and_print 179 196 +17 fflush_all - 9 +9 spawn 87 92 +5 rtcwake_main 455 453 -2 ... alarm_intr 93 84 -9 readcmd 1072 1062 -10 bb_ask 345 333 -12 more_main 845 832 -13 flush_stdout_stderr 42 23 -19 xfflush_stdout 27 - -27 flush_stderr 30 - -30 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397) Total: -366 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: revert the change where spawn reports exec failureDenys Vlasenko2009-10-111-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: make spawn() print "can't execute '%s'" on execv errorDenys Vlasenko2009-10-081-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: more portability fixes by Dan FandrichDenys Vlasenko2009-09-231-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* stop using non-standard macro, use WEXITSTATUS insteadDenys Vlasenko2009-06-071-2/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Compatibility fixes:Denis Vlasenko2009-03-201-10/+9
| | | | | | | | | grep: support -z find: support --mindepth together +45 bytes cpio: support -p (configurable, +230 bytes) libbb: tweaks for cpio
* runsvdir: alternative methon of supporting runsvdir-as-init. +66 bytes.Denis Vlasenko2008-11-061-4/+4
| | | | | *: s/int/pid_t where appropriate
* ash: fix a bug in standalone mode (corrupted getopt() state)Denis Vlasenko2008-10-201-2/+34
|
* mdev: do not follow symlinks in /sys (as was intended prior to rev 18811).Denis Vlasenko2008-07-061-1/+8
| | | | | | | | | | | | | If this breaks things, please document why! mdev,init: use shared code for fd sanitization function old new delta bb_daemonize_or_rexec 155 172 +17 mdev_main 500 505 +5 init_main 907 856 -51 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 22/-51) Total: -29 bytes
* revert last two commits. vfork cannot be used in subroutine,Denis Vlasenko2008-07-011-2/+6
| | | | | it trashes stack on return
* *: introduce and use xfork()Denis Vlasenko2008-07-011-3/+1
| | | | | | | | | | | | | function old new delta xfork - 20 +20 msh_main 1377 1380 +3 mod_process 455 446 -9 forkexit_or_rexec 30 17 -13 expand_variables 1434 1421 -13 open_transformer 91 76 -15 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/4 up/down: 23/-50) Total: -27 bytes
* *: introduce and use xvfork()Denis Vlasenko2008-07-011-3/+1
| | | | | | | | | | | | | | | | | | | | function old new delta time_main 1052 1285 +233 crontab_main 623 856 +233 ifupdown_main 2202 2403 +201 xvfork - 20 +20 passwd_main 1049 1053 +4 grave 1068 1066 -2 script_main 935 921 -14 vfork_or_die 20 - -20 vfork_compressor 206 175 -31 open_as_user 109 - -109 popen2 218 - -218 edit_file 910 690 -220 run_command 268 - -268 ------------------------------------------------------------------------------ (add/remove: 1/4 grow/shrink: 4/4 up/down: 691/-882) Total: -191 bytes
* *: introduce and use FAST_FUNC: regparm on i386, otherwise no-onDenis Vlasenko2008-06-271-15/+15
| | | | | | | text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
* - use EXIT_{SUCCESS,FAILURE}. No object-code changesBernhard Reutner-Fischer2008-05-191-2/+2
|
* fix english in commentDenis Vlasenko2008-04-131-3/+3
|
* ash: speed up NOFORK code in ash by eliminating second find_applet().Denis Vlasenko2008-04-131-1/+10
| | | | | | | | | | | | | | | | | | | | | | some code reduction along the way. function old new delta run_list 1971 1981 +10 run_nofork_applet_prime 181 182 +1 unsetcmd 97 96 -1 delete_cmd_entry 54 53 -1 describe_command 399 397 -2 cmdlookup 152 150 -2 evaltreenr 602 599 -3 evaltree 602 599 -3 clearcmdentry 101 98 -3 cdcmd 675 672 -3 hashcmd 305 301 -4 find_command 933 910 -23 evalcommand 1371 1229 -142 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/11 up/down: 11/-187) Total: -176 bytes
* libbb: introduce and use xrename and rename_or_warn.Denis Vlasenko2008-02-171-5/+0
|
* *: move getopt reset code to better place(s)Denis Vlasenko2008-01-281-20/+0
|
* tentatively fix getopt state corruption for NOFORK appletsDenis Vlasenko2008-01-271-2/+24
|
* libbb: introduce and use safe_waitpid (loops in EINTR)Denis Vlasenko2008-01-021-16/+21
| | | | | | | | | | | | | | | | | | | | | | *: use more approproate (shorter) versions of wait() function old new delta safe_waitpid - 48 +48 wait_any_nohang - 17 +17 send_tree 365 369 +4 processorstop 432 435 +3 text_yank 110 108 -2 make_human_readable_str 202 200 -2 crond_main 1368 1366 -2 handle_sigchld 49 43 -6 reapchild 166 159 -7 custom 260 250 -10 checkscript 191 177 -14 wait_nohang 17 - -17 wait_pid 43 - -43 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/7 up/down: 72/-103) Total: -31 bytes
* Further optimize applet tables; prettify build outputDenis Vlasenko2007-11-291-1/+1
| | | | | | | text data bss dec hex filename 775923 929 9100 785952 bfe20 busybox_old 775565 929 9100 785594 bfcba busybox_unstripped
* reorganize applet table. Eliminates pointers to names.Denis Vlasenko2007-11-281-11/+11
| | | | | | | | | Should be a big win for libbusybox. busybox wins too: text data bss dec hex filename 776524 929 9100 786553 c0079 busybox_old 775903 929 9100 785932 bfe0c busybox_unstripped
* get rid of global "struct bb_applet *current_applet"Denis Vlasenko2007-10-101-7/+3
|
* 'simple' error message functions by Loic Grenie <loic.grenie@gmail.com>.Denis Vlasenko2007-10-011-1/+1
| | | | | 263 bytes saved.
* make standalone httpd work on NOMMU machinesDenis Vlasenko2007-08-181-5/+10
|
* start_stop_daemon: NOMMU fix; smaller fixesDenis Vlasenko2007-07-311-2/+2
|
* init: make sure fd 0,1,2 are not closed, + related optimizations.Denis Vlasenko2007-06-141-6/+6
| | | | | | init_main 929 920 -9 bb_daemonize_or_rexec 145 127 -18
* make busybox --install work even if /proc/self/exe doesn't existDenis Vlasenko2007-06-081-2/+2
| | | | | | | | # size busybox_old busybox_unstripped text data bss dec hex filename 680095 2704 15648 698447 aa84f busybox_old 680099 2704 15648 698451 aa853 busybox_unstripped
* hush: fix handling of unmatched ${name (without closing '}') -Denis Vlasenko2007-05-241-1/+4
| | | | | | | was eating all remaining input, potentially megabytes. nofork: save/restore die_jmp too nofork: use -2222 instead of -111 as "special" return valur for zero (-111 is used by some applets. -2222 won't fit in exitcode and thus safer)
* more compile fixes from randomconfig runDenis Vlasenko2007-05-171-0/+2
|
* hush: fix nofork + ctrl-Z clobbering of globalsDenis Vlasenko2007-04-281-12/+29
|