From 05743d79496cf96e9f6f645b6bbc165d51e6aa5c Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 10 Feb 2008 12:10:08 +0000 Subject: hush: reinstate `cmd` handling for NOMMU (with fat big warning). hush: fix a case where none of pipe members could be started because of fork failure hush: rename functions: xxx_real -> xxx hush: try to add a bit more of vfork-friendliness hush: add rudimentary design docs hush: add TODO (newly discovered bug with globbing) --- shell/hush_doc.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 shell/hush_doc.txt (limited to 'shell/hush_doc.txt') diff --git a/shell/hush_doc.txt b/shell/hush_doc.txt new file mode 100644 index 000000000..a3ead590c --- /dev/null +++ b/shell/hush_doc.txt @@ -0,0 +1,39 @@ + This is how hush runs commands: + +/* callsite: process_command_subs */ +generate_stream_from_list(struct pipe *head) - handles `cmds` + create UNIX pipe + [v]fork + child: + redirect pipe output to stdout + _exit(run_list(head)); /* leaks memory */ + parent: + return UNIX pipe's output fd + /* head is freed by the caller */ + +/* callsite: parse_and_run_stream */ +run_and_free_list(struct pipe *) + run_list(struct pipe *) + free_pipe_list(struct pipe *) + +/* callsites: generate_stream_from_list, run_and_free_list, pseudo_exec, run_pipe */ +run_list(struct pipe *) - handles "cmd; cmd2 && cmd3", while/for/do loops + run_pipe - for every pipe in list + +/* callsite: run_list */ +run_pipe - runs "cmd1 | cmd2 | cmd3 [&]" + run_list - used if only one cmd and it is of the form "{ cmd4; cmd5 && cmd6; }" + forks for every cmd if more than one cmd or if & is there + pseudo_exec - runs each "cmdN" (handles builtins etc) + +/* callsite: run_pipe_real */ +pseudo_exec - runs "cmd" (handles builtins etc) + exec - execs external programs + run_list - used if cmdN is "(cmds)" or "{cmds;}" + /* problem: putenv's malloced strings into environ - + ** with vfork they will leak into parent process + */ + /* problem with ENABLE_FEATURE_SH_STANDALONE: + ** run_applet_no_and_exit(a, argv) uses exit - this can interfere + ** with vfork - switch to _exit there? + */ -- cgit v1.2.3