ia64/xen-unstable

changeset 4166:aeccd691af4c

bitkeeper revision 1.1236.34.7 (423735acABhfn7rysHwGJkcVOLD6GA)

XCS cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 15 19:21:16 2005 +0000 (2005-03-15)
parents d8941e2abcf0
children 6a97e01e0c4e
files tools/misc/xend
line diff
     1.1 --- a/tools/misc/xend	Tue Mar 15 18:19:23 2005 +0000
     1.2 +++ b/tools/misc/xend	Tue Mar 15 19:21:16 2005 +0000
     1.3 @@ -101,11 +101,16 @@ def check_user():
     1.4  def xcs_running():
     1.5      """ See if the control switch is running.
     1.6      """	
     1.7 +    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     1.8      try:
     1.9 -	xcs_pidfile = open(XCS_PIDFILE)
    1.10 -    except IOError:
    1.11 -	return(0)
    1.12 -    xcs_pidfile.close()
    1.13 +        s.connect( (XCS_PATH) )
    1.14 +        s.close()
    1.15 +    except:
    1.16 +        try:
    1.17 +            os.remove(XCS_PIDFILE)
    1.18 +        except:
    1.19 +            pass
    1.20 +	return 0
    1.21      return 1
    1.22      
    1.23  def start_xcs():
    1.24 @@ -113,6 +118,8 @@ def start_xcs():
    1.25          if os.fork():
    1.26              time.sleep(0.1) # let xcs start
    1.27          else:
    1.28 +            if not os.path.isdir(os.path.dirname(XCS_PATH)):
    1.29 +                os.makedirs(os.path.dirname(XCS_PATH))
    1.30              try:
    1.31                  os.execvp(XCS_EXEC, XCS_ARGS)
    1.32              except:
    1.33 @@ -129,12 +136,11 @@ def start_xcs():
    1.34  def stop_xcs():
    1.35      try:
    1.36  	xcs_pidfile = open(XCS_PIDFILE)
    1.37 -    except IOError:
    1.38 -	return
    1.39 -    xcs_pid = int(xcs_pidfile.read().strip())
    1.40 -    os.kill(xcs_pid, signal.SIGTERM)
    1.41 -    xcs_pidfile.close()
    1.42 -    
    1.43 +        xcs_pid = int(xcs_pidfile.read().strip())
    1.44 +        os.kill(xcs_pid, signal.SIGTERM)
    1.45 +        xcs_pidfile.close()
    1.46 +    except:
    1.47 +	return    
    1.48              
    1.49  def main():
    1.50      try: