hush problem with the exec command

Denys Vlasenko vda.linux at googlemail.com
Thu Mar 20 12:18:12 UTC 2008


On Monday 03 March 2008 01:39, Martinb_ARM_NOMMU_KISSDVD wrote:
> If I try to use the exec from a script it will fail
> I’m not sure if this is a old bug because i never did use the hush as a
> active shell
> (I always did use lash 1.1)
> 
> to reproduce i did:
> 
> 1- make a simple script named testscript
> 
> /paste
> #!/bin/hush
> 
> export TVOFF=`echo hallo`
> echo $TVOFF
> /endpaste
> 
> Run this from prompt will run ok
> 
> If I run this with the exec my telnet is exiting
...
> 
> I repeat:
> if i just run this from console with:
> ./testscript
> its ok
> 
> If I run this from console with:
> exec ./testscript
> It will exit / fail

Well, this is exactly what should happen.
"exec ..." in shell means literally to do exec() system call,
which will _replace_ shell process with new process, and if
that new process exits, there is nothing left.

In case of telnet, telnetd, which created shell in the first place,
will get SIGCHLD from exited process and will close the connection.

I just did in KDE's konsole:

bash-3.2# cat z
#!/bin/sh
export TVOFF=`echo hallo`
echo $TVOFF
bash-3.2# ./z
hallo
bash-3.2# exec ./z
[BLAMM!!! konsole window has closed. Probably too fast for me
 to see last "hallo"]

I tried lash from 1.6.0, it does the same. Can you give an example which
worked with lash but doesn't work with hush?
--
vda

--
vda



More information about the busybox mailing list