On 11/02/2015 02:09 PM, Tom Eastep wrote:
> On 11/02/2015 09:27 AM, matt darfeuille wrote:
>>
>> With the current code the return value of the function
>> syslog_circular_buffer is 1 instead of 0!
>>
>> It looks like return 0 does not break the loops!
>>
>> So what I did:
>> syslog_circular_buffer() {
>> local pid
>> local tty
>> local flags
>> local time
>> local path
>> local args
>> local arg
>>
>> ps w 2> /dev/null | while read pid tty stat time path args; do
>> case $path in
>> syslogd|*/syslogd)
>> for arg in $args; do
>> case $arg in
>> -C*)
>> return 0
>> ;;
>> esac
>> done
>> ;;
>> logd|*/logd)
>> for arg in $args; do
>> case $arg in
>> -S*)
>> return 0
>> ;;
>> *)
>> return 1
>> ;;
>> esac
>> done
>> ;;
>> esac
>> done
>>
>> if [ $? -ne 0 ]; then
>> return 1
>> fi
>> }
>>
>> Basicly it needs to break first from the loop and then the function
>> needs to return 0 if there is a match and 1 if there is no match!
>>
>> Hopefully you will understant what I am trying to say!!!:)
>>
>
> I tested the above and if fails to find a running 'syslogd -C16' unless
> that process is the first process displayed by 'ps -w'. The while loop
> is running in a sub-shell, so the 'return' just exits that sub-shell.
>
> I've gone back to using 'echo':
>
This also works and is a bit cleaner:
syslog_circular_buffer() {
local pid
local tty
local flags
local time
local path
local args
local arg
ps w 2> /dev/null | (
while read pid tty stat time path args; do
case $path in
syslogd|*/syslogd)
for arg in $args; do
case $arg in
-C*)
return 0
;;
esac
done
;;
logd|*/logd)
for arg in $args; do
case $arg in
-S*)
return 0
;;
esac
done
;;
esac
done
return 1 )
}
setup_logread() {
[ -z "$LOGFILE" ] && LOGFILE=/var/log/messages
if syslog_circular_buffer; then
LOGFILE=logread
...
That's what I will release,
-Tom
--
Tom Eastep \ When I die, I want to go like my Grandfather who
Shoreline, \ died peacefully in his sleep. Not screaming like
Washington, USA \ all of the passengers in his car
http://shorewall.net \________________________________________________
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------
_______________________________________________ Shorewall-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/shorewall-users
