cling
cling copied to clipboard
fork(); messes with interpritor.
- [ ] Checked for duplicates
Describe the bug
When using the C function: fork() it results in the interpreter getting bugged and not allowing typing properly(eg. characters would be in the wrong order, would have the wrong characters, etc...)
Expected behavior
I expected it to either error, or allow simultaneous input of some sort.
To Reproduce
open the interpritor (eg. run cling) and run
#include <unistd.h>
fork();
and then type any code/text into the interpreter.
Setup
cling -version
: 0.9 (package manager says 0.9-1). It might also be worth saying that this was a bug in earlier versions(since I first installed cling, not sure what version), but I'm only now reporting it.
operating system: Manjaro Linux x86_64
obtained cling from the arch linux AUR (https://aur.archlinux.org/packages/cling)
Additional context
Could just be a bug with how fork() is coded in C, but I thought that I should bring it up nevertheless.
The same behavior happens with std::async
, see this issue https://github.com/root-project/cling/issues/321. The solution is putting everything in a function and catch the thread, before you go back to the interactive prompt.
Okay, catching the thread is sometimes not possible with fork()
but maybe this knowledge helps. The Interactive prompt and the executed code uses the same program thread (also the same memory).