Commit ab6dea0a authored by sergeyu's avatar sergeyu Committed by Commit bot

Update linux_me2me_host.py to exit when Ctrl-C is pressed.

Previously when Ctrl-C is pressed the script would print a message that
says it was interrupted, but wouldn't actually quit. Added explicit
exit(1) call in sigint_handler() to ensure it quits as expected.

Review-Url: https://codereview.chromium.org/2537673002
Cr-Commit-Position: refs/heads/master@{#435063}
parent e3f1197b
...@@ -870,11 +870,11 @@ class ParentProcessLogger(object): ...@@ -870,11 +870,11 @@ class ParentProcessLogger(object):
false otherwise. false otherwise.
""" """
# If Ctrl-C is pressed, inform the user that the daemon is still running. # If Ctrl-C is pressed, inform the user that the daemon is still running.
# This signal will cause the read loop below to stop with an EINTR IOError.
def sigint_handler(signum, frame): def sigint_handler(signum, frame):
_ = signum, frame _ = signum, frame
print("Interrupted. The daemon is still running in the background.", print("Interrupted. The daemon is still running in the background.",
file=sys.stderr) file=sys.stderr)
sys.exit(1)
signal.signal(signal.SIGINT, sigint_handler) signal.signal(signal.SIGINT, sigint_handler)
...@@ -897,7 +897,6 @@ class ParentProcessLogger(object): ...@@ -897,7 +897,6 @@ class ParentProcessLogger(object):
# Print lines as they're logged to the pipe until EOF is reached or readline # Print lines as they're logged to the pipe until EOF is reached or readline
# is interrupted by one of the signal handlers above. # is interrupted by one of the signal handlers above.
host_ready = False host_ready = False
try:
for line in iter(self._read_file.readline, ''): for line in iter(self._read_file.readline, ''):
if line[:4] == "MSG:": if line[:4] == "MSG:":
sys.stderr.write(line[4:]) sys.stderr.write(line[4:])
...@@ -905,9 +904,6 @@ class ParentProcessLogger(object): ...@@ -905,9 +904,6 @@ class ParentProcessLogger(object):
host_ready = True host_ready = True
else: else:
sys.stderr.write("Unrecognized command: " + line) sys.stderr.write("Unrecognized command: " + line)
except IOError as e:
if e.errno != errno.EINTR:
raise
print("Log file: %s" % os.environ[LOG_FILE_ENV_VAR], file=sys.stderr) print("Log file: %s" % os.environ[LOG_FILE_ENV_VAR], file=sys.stderr)
return host_ready return host_ready
......
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