1
1
#! /bin/sh
2
2
#
3
- # $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.9 2001/02/1006:12:15 momjian Exp $
3
+ # $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.10 2001/02/1010:27:28 petere Exp $
4
4
#
5
5
6
6
CMDNAME=` basename$0 `
@@ -38,8 +38,6 @@ EffectiveUser=`id -n -u 2>/dev/null || whoami 2>/dev/null`
38
38
# This is based on RedHat 5.2.
39
39
#
40
40
if [` uname` = ' Linux' ]; then
41
- ipcs_id=
42
- ipcs_lpid=
43
41
did_anything=
44
42
45
43
if ps x| grep -s' [p]ostmaster' > /dev/null2>&1 ; then
@@ -48,34 +46,36 @@ if [ `uname` = 'Linux' ]; then
48
46
fi
49
47
50
48
# shared memory
51
- for val in ` ipcs -m -p| grep' ^[0-9]' | awk' {printf "%s %s\n", $1, $3, $4}' `
49
+ for val in ` ipcs -m -p| grep' ^[0-9]' | awk' {printf "%s:%s: %s\n", $1, $3, $4}' `
52
50
do
53
- if [-z " $ipcs_id " ]; then
54
- ipcs_id=$val
55
- # Note: We can do -n here, because we know the platform.
56
- echo -n" Shared memory$ipcs_id ..."
57
- continue
58
- fi
51
+ save_IFS=$IFS
52
+ IFS=:
53
+ set X$val
54
+ shift
55
+ IFS=$save_IFS
56
+ ipcs_shmid=$1
57
+ ipcs_cpid=$2
58
+ ipcs_lpid=$3
59
59
60
- ipcs_lpid=$val
60
+ # Note: We can do -n here, because we know the platform.
61
+ echo -n" Shared memory$ipcs_shmid ..."
61
62
62
63
# Don't do anything if process still running.
63
64
# (This check is conceptually phony, but it's
64
65
# useful anyway in practice.)
65
- ps hj$ipcs_lpid > /dev/null2>&1
66
+ ps hj$ipcs_cpid $ipcs_lpid > /dev/null2>&1
67
+ if [$? -eq 0 ]; then
68
+ echo " skipped; process still exists (pid$ipcs_cpid or$ipcs_lpid )."
69
+ continue
70
+ fi
71
+
72
+ # try remove
73
+ ipcrm shm$ipcs_shmid
66
74
if [$? -eq 0 ]; then
67
- echo " skipped. Process still exists (pid $ipcs_lpid ). "
75
+ did_anything=t
68
76
else
69
- # try remove
70
- ipcrm shm$ipcs_id
71
- if [$? -eq 0 ]; then
72
- did_anything=t
73
- else
74
- exit
75
- fi
77
+ exit
76
78
fi
77
- ipcs_id=
78
- ipcs_lpid=
79
79
done
80
80
81
81
# semaphores