ipc linux 测试工具,Linux IPC资源清理 – 笑遍世界的测试技术 – 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园…

#!/bin/sh

#

# ipcclean.sh

#

CMDNAME=`basename $0`

if [ “$1” = ‘–o “$1” = “–help” ]; then

echo “$CMDNAME cleans up shared memory and semaphores from aborted PostgreSQL”

echo “backends.”

echo

echo “Usage:”

echo ”  $CMDNAME”

echo

echo “Note: Since the utilities underlying this scrīpt are very different”

echo “from platform. to platform, chances are that it might not work on”

echo “yours. If that is the case, please write to “

echo “so that your platform. can be supported in the future.”

exit 0

fi

if [ “$USER” = ‘root’ -o “$LOGNAME” = ‘root’ ]

then

(

echo “$CMDNAME: cannot be run as root” 1>&2

echo “Please log in (using, e.g., “su””) as the (unprivileged) user that”” 1>&2

echo “”owned the server process.”” 1>&2

) 1>&2

exit 1

fi

EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`

#———————————–

# List of platform-specific hacks

# Feel free to add yours here.

#———————————–

#

# This is QNX 4.25

#

if [ `uname` = ‘QNX’ ]; then

if ps -eA  | grep -s ‘[p]ostmaster’ >/dev/null 2>&1 ; then

echo “”$CMDNAME: a postmaster is still running”” 1>&2

exit 1

fi

rm -f /dev/shmem/PgS*

exit $/p>

fi

#

# This is based on RedHat 5.2.  这里之后是该脚本的核心。

#

if [ `uname` = ‘Linux’ ]; then

did_anything=

if ps x | grep -s ‘[p]ostmaster’ >/dev/null 2>&1 ; then

echo “”$CMDNAME: a postmaster is still running”” 1>&2

exit 1

fi

# shared memory

for val in `ipcs -m -p | grep ‘^[0-9]’ | awk ‘{printf “”%s:%s:%sn””

来源:$3

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年4月8日
下一篇 2021年4月8日

相关推荐