mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Changed script execution behavior to fork before running. Causes more reliable execution but can leave zombies.
This commit is contained in:
13
misc.py
13
misc.py
@@ -46,6 +46,19 @@ def RunRegex(regex,string):
|
||||
def WriteLine(file,text):
|
||||
file.write(text + "\n")
|
||||
|
||||
def ExecuteScript(script):
|
||||
pid = os.fork()
|
||||
if not pid:
|
||||
os.setsid()
|
||||
os.umask(0)
|
||||
pid = os.fork()
|
||||
if not pid:
|
||||
print Run('./run-script.py ' + script)
|
||||
os._exit(0)
|
||||
os._exit(0)
|
||||
os.wait()
|
||||
|
||||
|
||||
def ReadFile(filename):
|
||||
if not os.path.exists(filename):
|
||||
return None
|
||||
|
||||
@@ -287,7 +287,7 @@ class Wireless(Controller):
|
||||
The first available wireless interface.
|
||||
|
||||
"""
|
||||
return wnettools.GetWirelessInterfaces()
|
||||
wnettools.GetWirelessInterfaces()
|
||||
|
||||
|
||||
def Disconnect(self):
|
||||
@@ -295,7 +295,7 @@ class Wireless(Controller):
|
||||
wiface = wnettools.WirelessInterface(self.wireless_interface, self.wpa_driver)
|
||||
if self.disconnect_script != None:
|
||||
print 'Running wireless network disconnect script'
|
||||
misc.Run(self.disconnect_script)
|
||||
misc.ExecuteScript(self.disconnect_script)
|
||||
|
||||
wiface.SetAddress('0.0.0.0')
|
||||
wiface.Down()
|
||||
@@ -356,7 +356,7 @@ class WirelessConnectThread(ConnectThread):
|
||||
# Execute pre-connection script if necessary
|
||||
if self.before_script != '' and self.before_script != None:
|
||||
print 'Executing pre-connection script'
|
||||
print misc.Run('run-script.py ' + self.before_script)
|
||||
print misc.ExecuteScript(self.before_script)
|
||||
|
||||
# Put it down
|
||||
print 'Interface down'
|
||||
@@ -445,8 +445,8 @@ class WirelessConnectThread(ConnectThread):
|
||||
|
||||
#execute post-connection script if necessary
|
||||
if misc.Noneify(self.after_script):
|
||||
print 'executing post connection script'
|
||||
print misc.Run('./run-script.py ' + self.after_script)
|
||||
print 'Executing post-connection script'
|
||||
misc.ExecuteScript(self.after_script)
|
||||
|
||||
self.SetStatus('done')
|
||||
print 'Connecting thread exiting.'
|
||||
@@ -563,8 +563,8 @@ class WiredConnectThread(ConnectThread):
|
||||
|
||||
# Execute pre-connection script if necessary
|
||||
if self.before_script != '' and self.before_script != None:
|
||||
print 'Executing pre-connection script'
|
||||
print misc.Run('run-script.py ' + self.before_script)
|
||||
print 'executing pre-connectiong script'
|
||||
misc.ExecuteScript(self.before_script)
|
||||
|
||||
# Put it down
|
||||
print 'Interface down'
|
||||
@@ -626,7 +626,7 @@ class WiredConnectThread(ConnectThread):
|
||||
#execute post-connection script if necessary
|
||||
if misc.Noneify(self.after_script):
|
||||
print 'executing post connection script'
|
||||
print misc.Run('./run-script.py ' + self.after_script)
|
||||
misc.ExecuteScript(self.after_script)
|
||||
|
||||
self.SetStatus('done')
|
||||
print 'Connecting thread exiting.'
|
||||
|
||||
Reference in New Issue
Block a user