July 5th Thursday (七月 五日 木曜日)
2007-08-04 17:20
483 查看
A contrl script puzzled me lots days. Today I finally got a correct version.
#!/bin/bash
#
# sinetrecvctl SI-net receiver damon control script
#
# description: SI-net receiver daemon is SI-net communication proccess.
### Source function library.
if [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
. /etc/init.d/functions
fi
SERVER=/usr/local/sbin/sinetrecv
SERVER_NAME=sinetrecv
CHECK_PROG=/usr/local/sbin/sinetrecv_check.sh
CHECK_PROG_NAME=sinetrecv_check.sh
prog="$SERVER"
RETVAL=0
umask 077
start() {
# check the existance of offline file.
if [ ! -f /tmp/online ]; then
echo "sinetrecv: This is off-line mode."
return 0
fi
# make directory for socket path file.
if [ ! -d /tmp/bws ] ; then
mkdir /tmp/bws
fi
if [ ! -d /tmp/bws/socket ] ; then
mkdir /tmp/bws/socket
fi
# check the existance of the lock file.
if [ -f /var/lock/subsys/sinetrecv ]; then
echo "sinetrecv already exists."
else
echo -n $"Starting $prog: "
$prog &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sinetrecv
$CHECK_PROG &
fi
return $RETVAL
}
stop() {
echo -n $"Shutting down $CHECK_PROG: "
killall $CHECK_PROG_NAME
RETVAL=$?
echo
#[ $RETVAL -eq 0 ] && rm -f /tmp/sinetrecv_check.lock
rm -f /tmp/sinetrecv_check.lock
echo -n $"Shutting down $prog: "
killall sleep
killall $SERVER_NAME
RETVAL=$?
#echo
#[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sinetrecv
rm -f /var/lock/subsys/sinetrecv
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
There is a trap in code.
if(shmid = shmget(GKCMN_COS_BUFFER_KEY, 0, 0666) >= 0){
...
}
The priority of "=" is lower than ">=", so the variable "shmid" get
the result of "shmget(GKCMN_COS_BUFFER_KEY, 0, 0666) >= 0". That is wrong!
So, this cause the following codes error.
#!/bin/bash
#
# sinetrecvctl SI-net receiver damon control script
#
# description: SI-net receiver daemon is SI-net communication proccess.
### Source function library.
if [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
. /etc/init.d/functions
fi
SERVER=/usr/local/sbin/sinetrecv
SERVER_NAME=sinetrecv
CHECK_PROG=/usr/local/sbin/sinetrecv_check.sh
CHECK_PROG_NAME=sinetrecv_check.sh
prog="$SERVER"
RETVAL=0
umask 077
start() {
# check the existance of offline file.
if [ ! -f /tmp/online ]; then
echo "sinetrecv: This is off-line mode."
return 0
fi
# make directory for socket path file.
if [ ! -d /tmp/bws ] ; then
mkdir /tmp/bws
fi
if [ ! -d /tmp/bws/socket ] ; then
mkdir /tmp/bws/socket
fi
# check the existance of the lock file.
if [ -f /var/lock/subsys/sinetrecv ]; then
echo "sinetrecv already exists."
else
echo -n $"Starting $prog: "
$prog &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sinetrecv
$CHECK_PROG &
fi
return $RETVAL
}
stop() {
echo -n $"Shutting down $CHECK_PROG: "
killall $CHECK_PROG_NAME
RETVAL=$?
echo
#[ $RETVAL -eq 0 ] && rm -f /tmp/sinetrecv_check.lock
rm -f /tmp/sinetrecv_check.lock
echo -n $"Shutting down $prog: "
killall sleep
killall $SERVER_NAME
RETVAL=$?
#echo
#[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sinetrecv
rm -f /var/lock/subsys/sinetrecv
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
There is a trap in code.
if(shmid = shmget(GKCMN_COS_BUFFER_KEY, 0, 0666) >= 0){
...
}
The priority of "=" is lower than ">=", so the variable "shmid" get
the result of "shmget(GKCMN_COS_BUFFER_KEY, 0, 0666) >= 0". That is wrong!
So, this cause the following codes error.
相关文章推荐
- July 23th Thursday (七月 二十三日 木曜日)
- April 5th Thursday (四月 五日 木曜日)
- July 19th Thursday (七月 十九日 木曜日)
- 2008 July 3th Thursday (七月 三日 木曜日)
- 2008 July 24th Thursday (七月 二十四日 木曜日)
- July 2nd Thursday (七月 二日 木曜日)
- 2008 July 17th Thursday (七月 十七日 木曜日)
- February 5th Thursday 2009 (二月 五日 木曜日)
- 2009 March 5th Thursday (三月 五日 木曜日)
- July 16th Thursday (七月 十六日 木曜日)
- July 12th Thursday (七月 十二日 木曜日)
- July 26th Thursday (七月 二十六日 木曜日)
- 2008 July 31th Thursday (七月 三十一日 木曜日)
- July 9th Thursday (七月 九日 木曜日)
- July 30th Thursday (七月 三十日 木曜日)
- 2008 July 10th Thursday (七月 十日 木曜日)
- 机器学习初步与微积分概率论-七月算法(julyedu.com)4 月机器学习算法班学习笔记
- 七月算法(julyedu.com)5 月深度学习班学习笔记-第一节数学基础
- 七月july
- Februray 15th Thursday (一月 十五日 木曜日)