On 20.06.2011 14:52, Mladen Turk wrote:
> On 06/20/2011 01:39 PM, Rainer Jung wrote:
>> Since Mladens change r918873 in March 2010 we use eval instead of exec
>> in the shell scripts. The svn log says:
>>
>> "Use eval instead direct call or exec command so that arguments with
>> spaces are properly handled"
>>
>> Mladen or whoever else understood this: can you give an example which
>> didn't work with the exec based scripts?
>>
> 
> eg.
> export JAVA_OPTS="$JAVA_OPTS \"-XX:OnError=gdb - %p\""

Thanks for the example.

> ... and
> We eval for start/stop so we can get the pid.

And this is broken now. We used $! with exec and we still use it with
eval. But with eval $! returns the pid of a child shell and the java
process id a child of that pid.

> since eval and exec behave differently when handling quoted args
> this was giving different results on catalina.sh run/start

Yes, I got it.

I experimented with "eval exec" (sic!) and it looks promising. The
following tiny script is useful for experimenting:

============================================
#!/bin/sh
dir='/var/tmp/with spaces'
arg1='-Dprop1=val1 with space'
arg2="-DpropX=y -DpropY=Z"
args="\"$arg1\" $arg2"

mkdir -p "$dir"
cp -p /usr/bin/sleep "$dir"

echo "Starting using eval ..."
eval \"$dir\"/sleep 60 $args &
pid=$!
echo "PID is: $pid"
ps -p $pid
kill -9 $pid

echo "Starting using eval exec ..."
eval exec \"$dir\"/sleep 60 $args &
pid=$!
echo "PID is: $pid"
ps -p $pid
kill -9 $pid

rm -rf "$dir"
============================================

I think "eval exec" is the right solution. Seems to behave nice for
whitespace and doesn't add an intermediate process between the startup
script and the Java process.

Regards,

Rainer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to