curl / Mailing Lists / curl-and-php / Single Mail


Re: CURL cannot be killed by a PHP SIGINT with custom signal handler

From: Rainer Canavan <>
Date: Wed, 11 Apr 2018 11:45:03 +0200

On Tue, Apr 10, 2018 at 8:02 PM, Jonathan Bull <> wrote:
> I have a PHP command line app with a custom shutdown handler:


> If I kill the script with `Ctrl+C` while a CURL request is in progress, it has no effect. The command just hangs. If I remove my custom shutdown handler, `Ctrl+C` kills the CURL request immediately.
> Why is CURL unkillable when I define a `SIGINT` handler? Thanks!

That appears to be a problem with the standard php curl bindings. It
doesn't happen with pecl_http (


   $shutdownHandler = function () {
       echo 'Exiting';

   pcntl_signal(SIGINT, $shutdownHandler);

   while (true) {
       $client = new http\Client();
       $client->enqueue(new http\Client\Request("GET",
       try {
       } catch (Exception $e) {

Received on 2018-04-11