2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 import os, sys, re, signal
25 from killSalomeWithPort import killMyPort, getPiDict
29 Kill all SALOME sessions belonging to the user.
31 user = os.getenv('USER')
32 # new-style dot-prefixed pidict file
33 #fpidict = getPiDict('(\d*)',hidden=True)
34 #problem with WIN32 path slashes
35 fpidict = getPiDict('#####',hidden=True)
36 dirpidict = os.path.dirname(fpidict)
37 fpidict = os.path.basename(fpidict)
38 fpidict = fpidict.replace('#####', '(\d*)')
39 fnamere = re.compile("^%s$" % fpidict)
41 for f in os.listdir(dirpidict):
44 killMyPort(mo.group(1))
51 # provide compatibility with old-style pidict file (not dot-prefixed)
52 #fpidict = getPiDict('(\d*)',hidden=False)
53 fpidict = getPiDict('#####',hidden=True)
54 dirpidict = os.path.dirname(fpidict)
55 fpidict = os.path.basename(fpidict)
56 fpidict = fpidict.replace('#####', '(\d*)')
57 fnamere = re.compile("^%s$" % fpidict)
59 for f in os.listdir(dirpidict):
62 killMyPort(mo.group(1))
69 # kill other processes
70 if sys.platform != 'win32':
72 cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
73 prc = commands.getoutput(cmd)
74 for field in prc.split():
76 os.kill(int(field), signal.SIGKILL)
83 if __name__ == "__main__":