Open samwilson opened 6 years ago
I don't know. Seems so. This is the same issue: https://stackoverflow.com/q/22329978
signalHandlerSetup()
will be executed but signalHandler()
will not be triggered.
Looks better! :) Thanks.
But still not quite, or at least some situations are odd, e.g. exiting the download command right after launching it (before any download has started):
$ ./bin/flickr-cli download
^C^C
In FlickrCliCommand.php line 368:
Signal 2
What's the point of the custom signal handling anyway? Just to allow exit only after pressing ctrl-c twice?
(Sorry, I didn't mean that to sound accusing! Just interested at the design choice.)
The thing about the custom signal handler was to gently shutdown the process. This is good to have a clean cut when, for example, downloading or uploading more than a few images, like 1000 images. For example you want to upload 1000 images at once and you decide to stop this process in the middle, you want to finish the current uploading image and it should not have an unknown state so you don't upload it twice and also to know where to continue uploading.
The second signal was to force stopping the current task. So that the user has the choice whether to let the process finish the current task or to forcefully stop it right now.
That does make sense. :-) Perhaps it just needs an additional prompt then, after the first ctrl-c? e.g. "Finishing current process. Press CTRL-C again to stop immediately." or something.
It doesn't work for me. The problem is that the Signal Setup is working but signalHandler()
will not be executed.
Edit: I tested it with a loop and sleep()
. Seems that sleep is catching the signal.
@samwilson I hope this fixed it. Please test the current develop version again.
I'm not sure what's going on with the signal handling, but I seem to be unable to ctrl-c when commands are running:
Is this a PHP 7.1 change?