Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Improve error handling when stop a scan. #163

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed
- Set loglevel to debug for some message. [#159](https://github.com/greenbone/ospd/pull/159)
- Improve error handling when stop a scan. [#163](https://github.com/greenbone/ospd/pull/163)

### Fixed
- Fix set permission in unix socket. [#157](https://github.com/greenbone/ospd/pull/157)
Expand Down
7 changes: 6 additions & 1 deletion ospd/ospd.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,12 @@ def stop_scan(self, scan_id):
except AttributeError:
logger.debug('%s: The scanner task stopped unexpectedly.', scan_id)

os.killpg(os.getpgid(scan_process.ident), 15)
try:
os.killpg(os.getpgid(scan_process.ident), 15)
except ProcessLookupError as e:
logger.info('%s: Scan already stopped %s.',
scan_id, scan_process.ident)

if scan_process.ident != os.getpid():
scan_process.join()
logger.info('%s: Scan stopped.', scan_id)
Expand Down