Skip to content

Commit c485d5b

Browse files
committed
Merge branch 'development' of github.com:gjbex/Python-for-systems-programming into development
2 parents bc741b9 + 9b41ab4 commit c485d5b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source-code/processes/monitor.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def main():
143143
if not options.files:
144144
inactive.extend(('read_files', 'write_files'))
145145
metrics = define_actions(inactive)
146+
found_process = False
146147
try:
147148
with open(options.output_file, 'w') if options.output_file else sys.stdout as file:
148149
print(status_header(metrics), file=file)
@@ -157,11 +158,13 @@ def main():
157158
print('Zombie process encountered', file=sys.stderr)
158159
print('\n'.join(process_info), file=file)
159160
time.sleep(options.delta)
160-
except psutil.NoSuchProcess:
161-
# the process has terminated, but this is to be expected
162-
pass
163161
except KeyboardInterrupt:
164162
pass
163+
except psutil.NoSuchProcess:
164+
if not found_process:
165+
print(f'Process {options.pid} does not exist', file=sys.stderr)
166+
return 1
167+
return 0
165168

166169

167170
if __name__ == '__main__':

0 commit comments

Comments
 (0)