Fixed delayed stderr output.

This commit is contained in:
Xaver K 2020-05-08 15:53:37 +02:00
parent 8e97b754aa
commit 7c39e852ef
3 changed files with 8 additions and 7 deletions

View File

@ -27,8 +27,8 @@ Works only on Linux and OS X. Windows is not supported yet. If you want to use t
```bash
git clone https://github.com/XaverKlemenschits/jupyter-c-kernel.git
cd jupyter-c-kernel
pip install -e .
cd jupyter_c_kernel && install_c_kernel --user
pip install -e . # for system install: sudo install .
cd jupyter_c_kernel && install_c_kernel --user # for sys install: sudo install_c_kernel
# now you can start the notebook
jupyter notebook
```

View File

@ -61,6 +61,10 @@ class RealTimeSubprocess(subprocess.Popen):
size -= 1
return res
stderr_contents = read_all_from_queue(self._stderr_queue)
if stderr_contents:
self._write_to_stderr(stderr_contents.decode())
stdout_contents = read_all_from_queue(self._stdout_queue)
if stdout_contents:
contents = stdout_contents.decode()
@ -80,10 +84,6 @@ class RealTimeSubprocess(subprocess.Popen):
else:
self._write_to_stdout(contents)
stderr_contents = read_all_from_queue(self._stderr_queue)
if stderr_contents:
self._write_to_stderr(stderr_contents.decode())
class CKernel(Kernel):
implementation = 'jupyter_c_kernel'
@ -152,6 +152,7 @@ class CKernel(Kernel):
def compile_with_gcc(self, source_filename, binary_filename, cflags=None, ldflags=None):
# cflags = ['-std=c89', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=c99', '-Wdeclaration-after-statement', '-Wvla', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=iso9899:199409', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
# cflags = ['-std=c99', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags
cflags = ['-std=c11', '-pedantic', '-fPIC', '-shared', '-rdynamic'] + cflags

View File

@ -60,7 +60,7 @@ char checkInputRequest() {
/* Need to define vscanf for c89.
TODO: This is a bit risky, since the underlying glibc does not
have to include this if it is old. If it does not, linking will fail.
The only safe way is reimplementing the whole function. */
The better way would be readin via sscanf. */
/* Read formatted input from stdin into argument list ARG.