|
From: Leif M. <le...@ta...> - 2007-03-14 05:49:25
|
Sorry for all the mails
Mark,
I figured it out. ps on OSX has a -w argument which tells ps to use
132 columns.
If you do it twice then it uses as many columns as necessary. It seems
to work the
same whether it is being run directly from a shell or from within a
subprocess.
Anyway. I have attached the fixed shell script with the following fix:
---
case "$DIST_OS" in
'macosx')
pidtest=`$PSEXE -ww -p $pid -o command | grep
"$WRAPPER_CMD" | tail -1`
;;
*)
pidtest=`$PSEXE -p $pid -o args | grep
"$WRAPPER_CMD" | tail -1`
;;
esac
---
Please let me know how it works for you.
Cheers,
Leif
Leif Mortenson wrote:
> Mark,
> Hi again. The following change will make this problem less likely,
> but it will still be
> encountered for narrow parent shells, or for long paths. Make this
> change in the
> getpid function of the script.
> ---
> case "$DIST_OS" in
> 'macosx')
> pidtest=`$PSEXE -p $pid -o command | grep
> "$WRAPPER_CMD" | tail -1`
> ;;
> *)
> pidtest=`$PSEXE -p $pid -o args | grep
> "$WRAPPER_CMD" | tail -1`
> ;;
> esac
> ---
>
> Still working on a better solution.
>
> Cheers,
> Leif
>
> Leif Mortenson wrote:
>
>> Mark,
>> I played around with this some more today trying to figure out what the
>> problem
>> could possibly be. The very first time I tried this today, I saw the
>> same thing you
>> did, BUT when I tried to repeat it, I was unable to. Every other
>> attempt results
>> in the script working perfectly. Are you seeing this intermittently or
>> does it happen
>> every time?
>>
>> Mark Leone wrote:
>>
>>
>>> I downloaded the script two different times from the URL you provided.
>>> I even tried reverting back to the script in the 3.2.3 distribution,
>>> just to see what happens. Although I get the stale pid error with both
>>> versions of the script, the distribution version throws some other
>>> error messages relating to a keyword error, I believe; so I'm
>>> satisfied that I'm actually executing the new version of the script.
>>>
>>>
>> Ok. That does indeed sound like you are running the correct thing.
>>
>> We are not seeing the same results, but I am attempting to understand why.
>> Could you edit your script and make following modifications in the getpid()
>> function:
>> ---
>> case "$DIST_OS" in
>> 'macosx')
>> echo "pidtest='$PSEXE -p $pid | grep
>> \"$WRAPPER_CMD\" | tail -1'"
>> pidtest=`$PSEXE -p $pid | grep "$WRAPPER_CMD" |
>> tail -1`
>> ;;
>> *)
>> pidtest=`$PSEXE -p $pid -o args | grep
>> "$WRAPPER_CMD" | tail -1`
>> ;;
>> esac
>> echo "pidtest=[$pidtest]"
>> ---
>> The changes are to add the two echo statements. Be careful of the
>> regular single
>> quotes in the first echo.
>>
>> On my system, when I check the status, I get the following:
>> ---
>> myhost:~/dev/sourceforge/wrapper/test myuser$ ./action status
>> pidtest='/bin/ps -p 2631 | grep
>> "/Users/myuser/dev/sourceforge/wrapper/test/../bin/wrapper" | tail -1'
>> pidtest=[ 2631 p2 S+ 0:00.15
>> /Users/myuser/dev/sourceforge/wrapper/test/../bin/wrapper
>> /Users/myuser/dev/sourceforge/wrappe]
>> Action Test Case is running (2631).
>> ---
>>
>> AHHHH I figured it out as I wrote this. See that the second pidtest
>> value output is
>> clipped at the end? That is because the output is coming from the piped
>> output of the
>> ps command. For some reason, OSX is truncating the output lines to the
>> width of
>> the parent shell even though that process is running in the background.
>>
>> If the shell width is wide, then this will work correctly. If however,
>> the shell with is
>> narrow enough that the wrapper process name is not fully listed then the
>> grep will
>> fail. See this example:
>> ---
>> myhost:~/dev/sourceforge/wrapper/test myuser$ ./action status
>> pidtest='/bin/ps -p 2631 | grep
>> "/Users/myuser/dev/sourceforge/wrapper/test/../bin/wrapper" | tail -1'
>> pidtest=[]
>> Removed stale pid file:
>> /Users/myuser/dev/sourceforge/wrapper/test/./action.pid
>> Action Test Case is not running.
>> ---
>>
>> In the above case, ps returns the following:
>> ---
>> PID TT STAT TIME COMMAND
>> 2631 p2 R+ 0:00.35 /Users/myuser/dev/sourceforge/wrapper/t
>> ---
>> So the grep is failing.
>>
>> Anyone have any ideas on how to resolve this? I will look into it as
>> well...
>>
>> Cheers,
>> Leif
>>
>>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wrapper-user mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapper-user
>
>
|