Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix multi-thread problem #176

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ static int enableRawMode(int fd) {
* no start/stop output control. */
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
/* output modes - disable post processing */
raw.c_oflag &= ~(OPOST);
/* FIXME: do not disable post processing, or there will be some problem
when using one thread to run linenoise, and another thread to write
something to stdout.Is there any problem? */
// raw.c_oflag &= ~(OPOST);
/* control modes - set 8 bit chars */
raw.c_cflag |= (CS8);
/* local modes - choing off, canonical off, no extended functions,
Expand Down Expand Up @@ -459,6 +462,7 @@ static void abInit(struct abuf *ab) {
}

static void abAppend(struct abuf *ab, const char *s, int len) {
if (len <= 0) return;
char *new = realloc(ab->b,ab->len+len);

if (new == NULL) return;
Expand All @@ -475,6 +479,7 @@ static void abFree(struct abuf *ab) {
* to the right of the prompt. */
void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
char seq[64];
seq[0] = '\0';
if (hintsCallback && plen+l->len < l->cols) {
int color = -1, bold = 0;
char *hint = hintsCallback(l->buf,&color,&bold);
Expand Down