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

curl-and-php

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

From: Jonathan Bull <jonathanbull_at_gmail.com>
Date: Tue, 10 Apr 2018 19:02:19 +0100

I have a PHP command line app with a custom shutdown handler:

    declare(ticks=1);

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

    pcntl_signal(SIGINT, $shutdownHandler);

    while (true) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://slow-responding-url.com');
        curl_exec($ch);
        curl_close($ch);
    }

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!
_______________________________________________
https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2018-04-10