From 38bc4e6a78c558f983702e74773892afe9191278 Mon Sep 17 00:00:00 2001 From: Barys Biankouski Date: Thu, 11 Jun 2015 13:02:15 +0300 Subject: [PATCH 1/2] Added Ctrl+C support to create-project command for unix-like systems --- src/Composer/Command/CreateProjectCommand.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 6f0f00fba..f25b2170a 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -290,6 +290,17 @@ EOT $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts); } + // handler Ctrl+C for unix-like systems + if (function_exists('pcntl_signal')) { + declare(ticks = 100); + $isPcntlHandler = true; + pcntl_signal(SIGINT, function() use ($directory) { + $fs = new Filesystem(); + $fs->removeDirectory($directory); + exit(); + }); + } + $io->writeError('Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')'); if ($disablePlugins) { From a59c46f781ff2c65390b764fd08de550cc53bcf9 Mon Sep 17 00:00:00 2001 From: Barys Biankouski Date: Thu, 11 Jun 2015 19:50:52 +0300 Subject: [PATCH 2/2] [create-project] If process terminated with SIGINT then 130 IMO will be returned. Remove unused variable --- src/Composer/Command/CreateProjectCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index f25b2170a..817bcf4cd 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -293,11 +293,10 @@ EOT // handler Ctrl+C for unix-like systems if (function_exists('pcntl_signal')) { declare(ticks = 100); - $isPcntlHandler = true; pcntl_signal(SIGINT, function() use ($directory) { $fs = new Filesystem(); $fs->removeDirectory($directory); - exit(); + exit(130); }); }