Skip to content

Commit bbb8766

Browse files
committed
Automatically close whole handler when all paths are removed
1 parent f7cf76f commit bbb8766

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/MKraemer/ReactInotify/Inotify.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ public function remove($descriptor)
9393
{
9494
if (isset($this->watchDescriptors[$descriptor])) {
9595
unset($this->watchDescriptors[$descriptor]);
96-
\inotify_rm_watch($this->inotifyHandler, $descriptor);
96+
97+
if ($this->watchDescriptors) {
98+
// there are still watch paths remaining => only remove this descriptor
99+
\inotify_rm_watch($this->inotifyHandler, $descriptor);
100+
} else {
101+
// no more paths watched => close whole handler
102+
$this->close();
103+
}
97104
}
98105
}
99106

0 commit comments

Comments
 (0)