Skip to content

Commit

Permalink
Improvement: invocations of openpyn --kill will now exit with status …
Browse files Browse the repository at this point in the history
…code 0
  • Loading branch information
1951FDG committed Mar 18, 2021
1 parent 8f71914 commit e05cc7d
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions openpyn/openpyn.py
Expand Up @@ -3,19 +3,20 @@
import argparse
import io
import json
import locale
import logging
import logging.handlers
import os
import shlex
import shutil
import signal
import subprocess
import sys
import tempfile
import time
import zipfile
from email.utils import parsedate
from pathlib import Path
import locale
from typing import List, Set

import coloredlogs
Expand Down Expand Up @@ -402,12 +403,7 @@ def run(init: bool, server: str, country_code: str, country: str, area: str, tcp
systemd.update_service(openpyn_options, run=True)

elif kill:
try:
kill_all()
# returns exit code 143
except RuntimeError as e:
logger.critical(e)
return 1
kill_all()

elif kill_flush:
if detected_os == "linux":
Expand All @@ -424,12 +420,7 @@ def run(init: bool, server: str, country_code: str, country: str, area: str, tcp
if internally_allowed:
network_interfaces = get_network_interfaces()
firewall.internally_allow_ports(network_interfaces, internally_allowed)
try:
kill_all()
# returns exit code 143
except RuntimeError as e:
logger.critical(e)
return 1
kill_all()

elif update:
try:
Expand Down Expand Up @@ -862,6 +853,11 @@ def kill_all() -> None:
if root_access is False:
root.obtain_root_access()

# ignore interrupt from keyboard (CTRL + C)
signal.signal(signal.SIGINT, signal.SIG_IGN)
# ignore termination signal (143)
signal.signal(signal.SIGTERM, signal.SIG_IGN)

kill_management_client()
kill_vpn_processes()

Expand Down

0 comments on commit e05cc7d

Please sign in to comment.