1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/bltins
Johnothan King 40b2c3c3d4 alias: Avoid unnecessary forks (re: ec888867) (#417)
The code used to fork subshells when creating/changing aliases will
always fork, even when the alias tree isn't changed:
   $ echo $(unalias --man 2> /dev/null; echo $$ ${.sh.pid})
   375097 375107
   $ alias foo=bar; echo $(alias -p foo; echo $$ ${.sh.pid})
   alias foo=bar 375097 375110
This is a bit inefficient, so this commit avoids forking a subshell
unless at least one change is made to the alias table.

src/cmd/ksh93/bltins/typeset.c:
- b_alias(), b_unalias(): Remove sh_subfork() calls.
- setall(): When creating an alias (name contains '='), fork a
  virtual subshell before calling nv_open() to add the node.
- unall():
  - When unsetting all aliases (-a), fork subshell before dtclear().
  - When unsetting one alias, fork subshell before nv_delete().
  - Move sh_pushcontext() and sh_popcontext() expansions so that
    sh_subfork() is not in between them, as that would cause
    program flow corruption or a crash.

Co-authored-by: Martijn Dekker <martijn@inlv.org>
2022-01-13 01:56:19 +00:00
..
alarm.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
cd_pwd.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
cflow.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
enum.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
getopts.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
hist.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
misc.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
mkservice.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
print.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
read.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
regress.c Fix various typos, man page issues and improve the documentation (#415) 2022-01-07 16:17:55 +00:00
sleep.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
test.c Fix various typos, man page issues and improve the documentation (#415) 2022-01-07 16:17:55 +00:00
trap.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
typeset.c alias: Avoid unnecessary forks (re: ec888867) (#417) 2022-01-13 01:56:19 +00:00
ulimit.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
umask.c INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
whence.c [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00