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 ## \file killSalome.py
24 # Stop all %SALOME servers from all sessions by killing them
27 import os, sys, re, signal
29 from killSalomeWithPort import killMyPort, getPiDict
33 Kill all SALOME sessions belonging to the user.
35 user = os.getenv('USER')
36 # new-style dot-prefixed pidict file
37 #fpidict = getPiDict('(\d*)',hidden=True)
38 #problem with WIN32 path slashes
39 fpidict = getPiDict('#####',hidden=True)
40 dirpidict = os.path.dirname(fpidict)
41 fpidict = os.path.basename(fpidict)
42 fpidict = fpidict.replace('#####', '(\d*)')
43 fnamere = re.compile("^%s$" % fpidict)
45 for f in os.listdir(dirpidict):
48 killMyPort(mo.group(1))
55 # provide compatibility with old-style pidict file (not dot-prefixed)
56 #fpidict = getPiDict('(\d*)',hidden=False)
57 fpidict = getPiDict('#####',hidden=True)
58 dirpidict = os.path.dirname(fpidict)
59 fpidict = os.path.basename(fpidict)
60 fpidict = fpidict.replace('#####', '(\d*)')
61 fnamere = re.compile("^%s$" % fpidict)
63 for f in os.listdir(dirpidict):
66 killMyPort(mo.group(1))
73 # kill other processes
74 if sys.platform != 'win32':
76 cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
77 prc = commands.getoutput(cmd)
78 for field in prc.split():
80 os.kill(int(field), signal.SIGKILL)
87 if __name__ == "__main__":