[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: process title with exec -a "" for oneself
From: |
Chet Ramey |
Subject: |
Re: Feature request: process title with exec -a "" for oneself |
Date: |
Wed, 4 Sep 2024 12:01:58 -0400 |
User-agent: |
Mozilla Thunderbird |
On 8/31/24 10:43 PM, Lockywolf wrote:
Dear Bash developers,
May I ask for a small feature to be added to bash?
At the moment exec changes IO redirections for the newly started
processes, but if there is no command for exec'ing, it changes those
redirections for the bash process itself.
The exec -a, however, allows setting the current process title (argv0)
only for the newly exec'ed processes, and "exec -a whatever" (without a
command) does nothing.
However it seems to be possible (albeit in a series of 8 syscalls) to
change the _current_ process' cmdline and argv0:
Currently, the shell's argc/argv are exposed to the user as
$1...$n - the positional parameters (argv[1]...argv[argc])
$# - the number of positional parameters (argc)
$0 - argv[0]
You can change the positional parameters and $# using the `set' builtin,
and, in bash versions newer than bash-4.4, you can change $0 by assigning
to BASH_ARGV0.
So I assume that you want to change the kernel's idea of the process
arguments as seen and displayed by `ps'. If so, I'm not really interested
in adding that as a feature. It doesn't seem to add anything for shell
users.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature