{"action":"created","issue":{"url":"https://api.github.com/repos/trentm/node-bunyan/issues/126","repository_url":"https://api.github.com/repos/trentm/node-bunyan","labels_url":"https://api.github.com/repos/trentm/node-bunyan/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/trentm/node-bunyan/issues/126/comments","events_url":"https://api.github.com/repos/trentm/node-bunyan/issues/126/events","html_url":"https://github.com/trentm/node-bunyan/issues/126","id":29129650,"number":126,"title":"bunyan-cli should ignore SIGINT when processing stdin from pipe.","user":{"login":"timborodin","id":4052337,"avatar_url":"https://avatars3.githubusercontent.com/u/4052337?v=3","gravatar_id":"","url":"https://api.github.com/users/timborodin","html_url":"https://github.com/timborodin","followers_url":"https://api.github.com/users/timborodin/followers","following_url":"https://api.github.com/users/timborodin/following{/other_user}","gists_url":"https://api.github.com/users/timborodin/gists{/gist_id}","starred_url":"https://api.github.com/users/timborodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timborodin/subscriptions","organizations_url":"https://api.github.com/users/timborodin/orgs","repos_url":"https://api.github.com/users/timborodin/repos","events_url":"https://api.github.com/users/timborodin/events{/privacy}","received_events_url":"https://api.github.com/users/timborodin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2014-03-10T20:29:22Z","updated_at":"2017-03-21T05:27:30Z","closed_at":"2014-08-25T06:21:32Z","body":"Steps to reproduce (mac here):\ntest.js\n\n``` javscript\nvar bunyan = require('bunyan');\nvar log = bunyan.createLogger({name: 'test'});\n\nvar timeout = setTimeout(function () {}, 10000);\n\nprocess.on('SIGINT', function () {\n    log.info('SIGINT here!');\n    clearTimeout(timeout);\n});\n```\n\nRun with, and hit ctrl+C in a second to send SIGINT:\n\n```\nnode test.js | bunyan\n```\n\nOutput:\n\n```\nnode test.js | bunyan\n^C\nevents.js:72\n        throw er; // Unhandled 'error' event\n              ^\nError: write EPIPE\n    at errnoException (net.js:904:11)\n    at Object.afterWrite (net.js:720:19)\n```\n\nCause seems to be pretty obvious:\n1. SIGINT is sent to all process in a process group.\n2. bunyan(-cli) process exists.\n3. test.js app tries to log to stdout and fails, because other side of a pipe is closed.\n\nSuggested solutions:\nbunyan-cli is purposed to analyse logs post-factum or realtime.\nIt should not react to SIGINT when processing stdin.\nIt should expect process on the left of '|' to terminate and process all it's output.\nAfter process on the left of '|' terminates bunyan-cli will correctly terminate after receiving EOF from stdin.\n\nI checked it adding a quick and dirty hack to bunyan:\n\n```\nglobal_processing_stdin = false;\n\nfunction processStdin(opts, stylize, callback) {\n    global_processing_stdin = true;\n        ...\n```\n\nand\n\n```\nfunction cleanupAndExit(code, signal) {\n    // Guard one call.\n    if (cleanedUp || global_processing_stdin) {\n        return;\n    }\n    ...\n```\n"},"comment":{"url":"https://api.github.com/repos/trentm/node-bunyan/issues/comments/287980868","html_url":"https://github.com/trentm/node-bunyan/issues/126#issuecomment-287980868","issue_url":"https://api.github.com/repos/trentm/node-bunyan/issues/126","id":287980868,"user":{"login":"trentm","id":46866,"avatar_url":"https://avatars0.githubusercontent.com/u/46866?v=3","gravatar_id":"","url":"https://api.github.com/users/trentm","html_url":"https://github.com/trentm","followers_url":"https://api.github.com/users/trentm/followers","following_url":"https://api.github.com/users/trentm/following{/other_user}","gists_url":"https://api.github.com/users/trentm/gists{/gist_id}","starred_url":"https://api.github.com/users/trentm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trentm/subscriptions","organizations_url":"https://api.github.com/users/trentm/orgs","repos_url":"https://api.github.com/users/trentm/repos","events_url":"https://api.github.com/users/trentm/events{/privacy}","received_events_url":"https://api.github.com/users/trentm/received_events","type":"User","site_admin":false},"created_at":"2017-03-21T05:27:30Z","updated_at":"2017-03-21T05:27:30Z","body":"reverted in bunyan@1.8.9, see discussion in #246"}}
{"actor":{"display_login":"trentm"}}