In bash
I would simply use exec -a
. How can I do this in busybox? Is it even possible, or will I have to write my own C program to call exec(3)
directly?
What version of busybox do you have? According to https://git.busybox.net/busybox/tree/shell/ash.c if one delves around for exec
one may encounter around line 9352 or so the following code which appears to support exec [-a customname] ...
execcmd(int argc UNUSED_PARAM, char **argv)
{
optionarg = NULL;
while (nextopt("a:") != '\0')
/* nextopt() sets optionarg to "-a ARGV0" */;
argv = argptr;
if (argv[0]) {
char *prog;
iflag = 0; /* exit on error */
mflag = 0;
optschanged();
/* We should set up signals for "exec CMD"
* the same way as for "CMD" without "exec".
* But optschanged->setinteractive->setsignal
* still thought we are a root shell. Therefore, for example,
* SIGQUIT is still set to IGN. Fix it:
*/
shlvl++;
setsignal(SIGQUIT);
/*setsignal(SIGTERM); - unnecessary because of iflag=0 */
/*setsignal(SIGTSTP); - unnecessary because of mflag=0 */
/*setsignal(SIGTTOU); - unnecessary because of mflag=0 */
prog = argv[0];
if (optionarg)
argv[0] = optionarg;
shellexec(prog, argv, pathval(), 0);
-
-
@ali1234 Then I think your busybox doesn't have this capability at all. – Gilles 'SO- stop being evil' Apr 27 '17 at 22:22
exec -a
is supported since Busybox 1.27, see also the answers to Is there a POSIX way of setting zeroth argument of a target application? for how to do achieve it some other way.
busybox sh --help
)? – Gilles 'SO- stop being evil' Apr 27 '17 at 22:20