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/include
Martijn Dekker bdc3069bfd Fix 'ps' output for hashbangless scripts on Linux/macOS
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
2021-09-12 05:34:52 +02:00
..
argnod.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
builtins.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
defs.h Fix backtick comsubs by making them act like $(modern) ones 2021-08-13 09:14:11 +02:00
edit.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
fault.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
fcin.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
history.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
io.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
jobs.h Fix backtick comsubs by making them act like $(modern) ones 2021-08-13 09:14:11 +02:00
lexstates.h Fix single quotes in expansion operator string (re: 5ed9ffd6) 2021-04-30 05:28:21 +01:00
name.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
national.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
nval.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
path.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
regress.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shell.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shlex.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shnodes.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shtable.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
streval.h Fix arithmetic assignment operations for multidimensional indexed arrays (#296) 2021-05-04 03:13:14 +01:00
terminal.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
test.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
timeout.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
ulimit.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
variables.h Fix $RANDOM to act consistently in subshells (#294) 2021-05-03 04:03:46 +01:00
version.h Fix 'ps' output for hashbangless scripts on Linux/macOS 2021-09-12 05:34:52 +02:00