mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
When invoking a script without an interpreter (#!hashbang) path, ksh forks, but there is no exec syscall in the child. The existing command line is overwritten in fixargs() with the name of the new script and associated arguments. In the generic/fallback version of fixargs() which is used on Linux and macOS, if the new command line is longer than the existing one, it is truncated. This works well when calling a script with a shorter name. However, it generates a misleading name in the common scenario where a script is invoked from an interactive shell, which typically has a short command line. For instance, if "/tmp/script" is invoked, "ksh" gets replaced with "/tm" in "ps" output. A solution is found in the fact that, on these systems, the environment is stored immediately after the command line arguments. This space can be made available for use by a longer command line by moving the environment strings out of the way. src/cmd/ksh93/sh/main.c: fixargs(): - Refactor BSD setproctitle(3) version to be more self-contained. - In the generic (Linux/macOS) version, on init (i.e. mode==0), if the command line is smaller than 128 bytes and the environment strings have not yet been moved (i.e. if they still immediately follow the command line arguments in memory), then strdup the environment strings, pointing the *environment[] members to the new strings and adding the length of the strings to the maximum command line buffer size. Reported-by: @gkamat Resolves: https://github.com/ksh93/ksh/pull/300 |
||
|---|---|---|
| .. | ||
| argnod.h | ||
| builtins.h | ||
| defs.h | ||
| edit.h | ||
| fault.h | ||
| fcin.h | ||
| history.h | ||
| io.h | ||
| jobs.h | ||
| lexstates.h | ||
| name.h | ||
| national.h | ||
| nval.h | ||
| path.h | ||
| regress.h | ||
| shell.h | ||
| shlex.h | ||
| shnodes.h | ||
| shtable.h | ||
| streval.h | ||
| terminal.h | ||
| test.h | ||
| timeout.h | ||
| ulimit.h | ||
| variables.h | ||
| version.h | ||