From 0548ca36071a985853af814b6a2f167cecca5794 Mon Sep 17 00:00:00 2001 From: Evgeniy Guseletov Date: Sun, 21 Sep 2014 21:53:18 +0300 Subject: [PATCH] Remove sockets on main shutdown --- EProcess/Adapter/PThreads.php | 4 ++++ EProcess/Adapter/SymfonyProcess.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/EProcess/Adapter/PThreads.php b/EProcess/Adapter/PThreads.php index d694406..a82b332 100644 --- a/EProcess/Adapter/PThreads.php +++ b/EProcess/Adapter/PThreads.php @@ -20,6 +20,10 @@ public function create($class, array $data = []) $node = uniqid('thread_'); $unix = sprintf('unix://tmp/%s.sock', $node); + register_shutdown_function(function() use ($unix) { + unlink($unix); + }); + $messenger = MessengerFactory::server($unix, $this->loop); $this->process = new Thread($unix, $class, $data); diff --git a/EProcess/Adapter/SymfonyProcess.php b/EProcess/Adapter/SymfonyProcess.php index 6e0bfac..d9baf54 100644 --- a/EProcess/Adapter/SymfonyProcess.php +++ b/EProcess/Adapter/SymfonyProcess.php @@ -58,6 +58,10 @@ public function create($class, array $data = []) $node = uniqid('thread_'); $unix = sprintf('unix://app/cache/%s.sock', $node); + register_shutdown_function(function() use ($unix) { + unlink($unix); + }); + $messenger = MessengerFactory::server($unix, $this->loop); $script = sprintf($this->script, EPROCESS_AUTOLOAD, $unix, $class, base64_encode($this->serialize($data)));