{"action":"created","issue":{"url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/3","repository_url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel","labels_url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/3/comments","events_url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/3/events","html_url":"https://github.com/brendan-rius/jupyter-c-kernel/issues/3","id":149333196,"number":3,"title":"Allow to read from stdin","user":{"login":"brendan-rius","id":5605817,"avatar_url":"https://avatars3.githubusercontent.com/u/5605817?v=3","gravatar_id":"","url":"https://api.github.com/users/brendan-rius","html_url":"https://github.com/brendan-rius","followers_url":"https://api.github.com/users/brendan-rius/followers","following_url":"https://api.github.com/users/brendan-rius/following{/other_user}","gists_url":"https://api.github.com/users/brendan-rius/gists{/gist_id}","starred_url":"https://api.github.com/users/brendan-rius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendan-rius/subscriptions","organizations_url":"https://api.github.com/users/brendan-rius/orgs","repos_url":"https://api.github.com/users/brendan-rius/repos","events_url":"https://api.github.com/users/brendan-rius/events{/privacy}","received_events_url":"https://api.github.com/users/brendan-rius/received_events","type":"User","site_admin":false},"labels":[{"id":347431528,"url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-04-19T02:49:45Z","updated_at":"2017-04-13T15:12:10Z","closed_at":null,"body":"So it is possible to use functions like `scanf`.\n\nThanks to @ryukinix for letting me know about this enhancement.\n"},"comment":{"url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/comments/293924287","html_url":"https://github.com/brendan-rius/jupyter-c-kernel/issues/3#issuecomment-293924287","issue_url":"https://api.github.com/repos/brendan-rius/jupyter-c-kernel/issues/3","id":293924287,"user":{"login":"spoorcc","id":1345842,"avatar_url":"https://avatars2.githubusercontent.com/u/1345842?v=3","gravatar_id":"","url":"https://api.github.com/users/spoorcc","html_url":"https://github.com/spoorcc","followers_url":"https://api.github.com/users/spoorcc/followers","following_url":"https://api.github.com/users/spoorcc/following{/other_user}","gists_url":"https://api.github.com/users/spoorcc/gists{/gist_id}","starred_url":"https://api.github.com/users/spoorcc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spoorcc/subscriptions","organizations_url":"https://api.github.com/users/spoorcc/orgs","repos_url":"https://api.github.com/users/spoorcc/repos","events_url":"https://api.github.com/users/spoorcc/events{/privacy}","received_events_url":"https://api.github.com/users/spoorcc/received_events","type":"User","site_admin":false},"created_at":"2017-04-13T15:12:10Z","updated_at":"2017-04-13T15:12:10Z","body":"I'm trying to implement this, but I'm a little stuck: \r\nMy idea is to override all `fgets` calls with `my_fgets` using a macro. This `my_fgets` in `master.c`  notifies its parent (subprocess.Popen in `kernel.py`) _somehow_ to send an `input_request` through `stdin_socket`. When `input_reply` is received from the frontend the data is piped to the stdin of subprocess.\r\n\r\nI managed to request and receive input from the frontend as such, which works just fine:\r\n```python\r\n def _raw_input(self, prompt, ident, parent):\r\n          # Flush output before making the request.\r\n          sys.stderr.flush()\r\n          sys.stdout.flush()\r\n\r\n          # Send the input request.\r\n          content = dict(prompt=prompt)\r\n          msg = self.session.send(self.stdin_socket, u'input_request', content, parent, ident=ident)\r\n\r\n          # Await a response.\r\n          ident,reply = self.session.recv(self.stdin_socket, 0)\r\n          try:\r\n              value = reply['content']['value']\r\n          except:\r\n              self.log.error(\"Got bad raw_input reply: %s\"%Message(parent))\r\n              value = ''\r\n          return value\r\n\r\n    def execute_request(self, stream, ident, parent):\r\n        ''' Wrap execture_request function to force input call '''\r\n        value = self._raw_input('Some info:', ident, parent)\r\n        self.log.warn('Value: {}'.format(value))\r\n        super(CKernel, self).execute_request(stream, ident, parent)\r\n```\r\n\r\n# Questions\r\nI cannot find or decide on a mechanism to notify from `master.c` to Python `subprocess` instance that input is requested:\r\n* Is there anybody with an opinion or a better suggestion than:\r\n    * Using `zmq` sockets directly from master.c?\r\n    * Introducing new messaging system between master.c and kernel.py?\r\n    * Piping some predefined message through stderr/stdout?\r\n* I looked into raising signals `SIGTTIN` and `SIGTTOU` ([good blog](http://curiousthing.org/sigttin-sigttou-deep-dive-linux)), but they appear to be used from parent-to-child and I want from child to parent."}}
{"actor":{"display_login":"spoorcc"}}