{"action":"closed","issue":{"url":"https://api.github.com/repos/mkoppanen/php-zmq/issues/28","labels_url":"https://api.github.com/repos/mkoppanen/php-zmq/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/mkoppanen/php-zmq/issues/28/comments","events_url":"https://api.github.com/repos/mkoppanen/php-zmq/issues/28/events","html_url":"https://github.com/mkoppanen/php-zmq/issues/28","id":1073096,"number":28,"title":"Signal handling broken","user":{"login":"dfa","id":278978,"avatar_url":"https://avatars.githubusercontent.com/u/278978?v=3","gravatar_id":"","url":"https://api.github.com/users/dfa","html_url":"https://github.com/dfa","followers_url":"https://api.github.com/users/dfa/followers","following_url":"https://api.github.com/users/dfa/following{/other_user}","gists_url":"https://api.github.com/users/dfa/gists{/gist_id}","starred_url":"https://api.github.com/users/dfa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfa/subscriptions","organizations_url":"https://api.github.com/users/dfa/orgs","repos_url":"https://api.github.com/users/dfa/repos","events_url":"https://api.github.com/users/dfa/events{/privacy}","received_events_url":"https://api.github.com/users/dfa/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2011-06-17T11:54:00Z","updated_at":"2016-01-09T01:48:08Z","closed_at":"2016-01-09T01:48:08Z","body":"Hi\r\n\r\nThe program should receive a `kill -HUP <pid>`, but while `recv()` is waiting for a message, the signal will not be received. It works in C but not in PHP.\r\n\r\n* Operating System: FreeBSD 8.2-RELEASE (i386)\r\n* PHP: 5.3.6 (with Xdebug v2.1.0)\r\n* zmq: 2.1.7\r\n* php-zmq: Fri Jun 3 09:17:33 2011 +0100 (b200f9d6173de6beef2afff853ad998d0a99f7f5)\r\n\r\nI'm not sure if it is a general PHP or php-zmq problem.\r\n\r\nThank you for your great work.\r\n\r\nBest regards,\r\nDom \r\n\r\n# PHP version\r\n\r\n````php\r\ndeclare(ticks = 1);\r\n\r\necho posix_getpid() . \"\\n\";\r\n\r\npcntl_signal(SIGHUP, 'sigHandler');\r\n\r\n$context = new ZMQContext();\r\n$responder = new ZMQSocket($context, ZMQ::SOCKET_REP);\r\n$responder->bind('tcp://127.0.0.1:5559');\r\n\r\n//while (true) {\r\n//    echo '.'; \r\n//    sleep(1);\r\n//}\r\n\r\nwhile ($request = $responder->recv()) {\r\n    echo 'Message received...' . \"\\n\";\r\n}\r\n\r\nfunction sigHandler()\r\n{\r\n    echo \"Caught SIGHUP...\\n\";\r\n}\r\n````\r\n\r\n# C version\r\n\r\n````C\r\nvoid sig_func(int sig)\r\n{\r\n    write(1, \"Caught signal HUP\\n\", 18);\r\n}\r\n\r\nint main()\r\n{\r\n    signal(SIGHUP, sig_func);\r\n\r\n    void *context = zmq_init (1);\r\n    \r\n    void *responder = zmq_socket (context, ZMQ_REP);\r\n    zmq_bind (responder, \"tcp://*:5555\");\r\n    \r\n    while (1) {\r\n        zmq_msg_t request;\r\n        zmq_msg_init (&request);\r\n        zmq_recv (responder, &request, 0);\r\n        printf (\"Received Hello\\n\");\r\n        zmq_msg_close (&request);\r\n    }\r\n    zmq_close (responder);\r\n    zmq_term (context);\r\n    return 0;\r\n}\r\n````"}}