{"action":"created","issue":{"url":"https://api.github.com/repos/joewalnes/websocketd/issues/117","labels_url":"https://api.github.com/repos/joewalnes/websocketd/issues/117/labels{/name}","comments_url":"https://api.github.com/repos/joewalnes/websocketd/issues/117/comments","events_url":"https://api.github.com/repos/joewalnes/websocketd/issues/117/events","html_url":"https://github.com/joewalnes/websocketd/issues/117","id":58127678,"number":117,"title":"C process reading from STDIN not exiting","user":{"login":"mitchi","id":198192,"avatar_url":"https://avatars.githubusercontent.com/u/198192?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchi","html_url":"https://github.com/mitchi","followers_url":"https://api.github.com/users/mitchi/followers","following_url":"https://api.github.com/users/mitchi/following{/other_user}","gists_url":"https://api.github.com/users/mitchi/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchi/subscriptions","organizations_url":"https://api.github.com/users/mitchi/orgs","repos_url":"https://api.github.com/users/mitchi/repos","events_url":"https://api.github.com/users/mitchi/events{/privacy}","received_events_url":"https://api.github.com/users/mitchi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-18T21:04:03Z","updated_at":"2015-02-19T01:08:59Z","closed_at":"2015-02-19T01:08:59Z","body":"Hello,\r\n\r\nI wanted to have this little utility (JSON to C STRING) work through websockets. \r\nIt works but the process stays alive after the work, since fgets is a blocking function. I don't know golang but can you close the stream ? It works with the command processor and doesn't block, can you do the same with websockets?\r\n\r\n```javascript\r\n#include <stdio.h>\r\n#include <string.h>\r\n#include <stdlib.h>\r\n\r\nchar transformLine(char *oldline, char *newline)\r\n{\r\n\tchar * oldp = oldline;\r\n\tchar * newp = newline;\r\n\t\r\n\t//Check for null ptrs\r\n\tif (oldline == NULL || newline == NULL) return -1;\r\n\r\n\t//Check to see if the line is valid\r\n\t*newp++ = '\"';\r\n\twhile (1) \r\n\t{\r\n\r\n\t\tif (*oldp == 13 || *oldp == 10 || *oldp == 0) {\r\n\t\t\t*newp++ = '\"';\r\n\t\t\t*newp++ = '\\n'; //comment this line to have single line json\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tif (*oldp == '\"') {\r\n\t\t\t*newp++ = '\\\\';\r\n\t\t\t*newp++ = '\"';\r\n\t\t\toldp++;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t*newp++ = *oldp++;\r\n\t}\r\n}\r\n\r\n\r\nint main(void)\r\n{\r\n\r\n\t//Read string from STDIN\r\n\tstatic char line[500];\r\n\tstatic char buffer[500];\r\n\t// Disable output buffering.\r\n    setbuf(stdout, NULL);\r\n\r\n\twhile (fgets(line, 500, stdin) != NULL) {\r\n\t\t\tmemset(buffer,0, 500);\r\n\t\t\ttransformLine(line, buffer);\r\n\t\t\tprintf(buffer);\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n\r\n}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/joewalnes/websocketd/issues/comments/74982476","html_url":"https://github.com/joewalnes/websocketd/issues/117#issuecomment-74982476","issue_url":"https://api.github.com/repos/joewalnes/websocketd/issues/117","id":74982476,"user":{"login":"asergeyev","id":715656,"avatar_url":"https://avatars.githubusercontent.com/u/715656?v=3","gravatar_id":"","url":"https://api.github.com/users/asergeyev","html_url":"https://github.com/asergeyev","followers_url":"https://api.github.com/users/asergeyev/followers","following_url":"https://api.github.com/users/asergeyev/following{/other_user}","gists_url":"https://api.github.com/users/asergeyev/gists{/gist_id}","starred_url":"https://api.github.com/users/asergeyev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asergeyev/subscriptions","organizations_url":"https://api.github.com/users/asergeyev/orgs","repos_url":"https://api.github.com/users/asergeyev/repos","events_url":"https://api.github.com/users/asergeyev/events{/privacy}","received_events_url":"https://api.github.com/users/asergeyev/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T01:08:59Z","updated_at":"2015-02-19T01:08:59Z","body":"Good, I'll close it then...\r\n\r\nYes, websockets is very different in nature from CGI,  websocketd makes them look similar."}}