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

Commit

Permalink
Merge pull request #163 from jjnicola/stop-scan-2
Browse files Browse the repository at this point in the history
Improve error handling when stop a scan.
  • Loading branch information
bjoernricks authored Oct 23, 2019
2 parents 0b01c21 + 985342f commit d19b35f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit d19b35f

Please sign in to comment.