Commit ad398393 by Graham Wallis Committed by Madhan Neethiraj

ATLAS-1733: updated atlas_stop.py script to work in Windows environment

parent 8fe110c3
......@@ -15,8 +15,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Signal handling is OS-specific because there is no SIGKILL on Windows.
import os
from signal import SIGTERM, SIGKILL
if os.name == "nt":
# Attempting to import SIGKILL on Windows would cause script to fail.
from signal import SIGTERM
else:
from signal import SIGTERM, SIGKILL
import sys
import traceback
import time
......@@ -68,8 +78,15 @@ def main():
#after 30 seconds kill it
time.sleep(30)
try:
sys.stderr.write("did not stop gracefully after 30 seconds seconds: killing with SIGKILL\n")
if os.name == "nt":
# If running on Windows then timeout termination uses SIGTERM instead of SIGKILL.
sys.stderr.write("did not stop gracefully after 30 seconds: killing process using SIGTERM\n")
os.kill(pid, SIGTERM)
else:
sys.stderr.write("did not stop gracefully after 30 seconds: killing process using SIGKILL\n")
os.kill(pid, SIGKILL)
except:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment