summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-10-08 21:31:29 +0200
committerGitHub <noreply@github.com>2018-10-08 21:31:29 +0200
commit1178e852068cc220e6d27757c7db79709a602971 (patch)
treed54bdb12759d481174f7588e5b3ce8eadbcc491d /core
parent6994a2a87d691b3bf869219cb21ca2ae6625a8d5 (diff)
parent311de17730174dae1f951bdf38a657e6c5453574 (diff)
downloadnextcloud-server-1178e852068cc220e6d27757c7db79709a602971.tar.gz
nextcloud-server-1178e852068cc220e6d27757c7db79709a602971.zip
Merge pull request #11664 from nextcloud/feature/noid/has-been-interrupted-throw-exception
Syntactic sugar for hasBeenInterrupted
Diffstat (limited to 'core')
-rw-r--r--core/Command/Base.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/Command/Base.php b/core/Command/Base.php
index dbf6c71b8f4..4eca5bcaab7 100644
--- a/core/Command/Base.php
+++ b/core/Command/Base.php
@@ -129,15 +129,19 @@ class Base extends Command implements CompletionAwareInterface {
}
/**
- * @return bool
+ * Throw InterruptedException when interrupted by user
+ *
+ * @throws InterruptedException
*/
- protected function hasBeenInterrupted() {
- // return always false if pcntl_signal functions are not accessible
- if ($this->php_pcntl_signal) {
- pcntl_signal_dispatch();
- return $this->interrupted;
- } else {
- return false;
+ protected function abortIfInterrupted() {
+ if ($this->php_pcntl_signal === false) {
+ return;
+ }
+
+ pcntl_signal_dispatch();
+
+ if ($this->interrupted === true) {
+ throw new InterruptedException('Command interrupted by user');
}
}