Make pipes blocking
This commit is contained in:
@@ -108,16 +108,14 @@ uint64_t main() {
|
||||
char chunk[64];
|
||||
uint64_t received;
|
||||
|
||||
while (1) {
|
||||
if ((received = read(0, sizeof(chunk), chunk))) {
|
||||
for (uint64_t i = 0; i < received; i++) {
|
||||
if (chunk[i] == '\n') {
|
||||
line[offset] = '\0';
|
||||
execute(line);
|
||||
offset = 0;
|
||||
} else if (offset < 255) {
|
||||
line[offset++] = chunk[i];
|
||||
}
|
||||
while ((received = read(0, sizeof(chunk), chunk))) {
|
||||
for (uint64_t i = 0; i < received; i++) {
|
||||
if (chunk[i] == '\n') {
|
||||
line[offset] = '\0';
|
||||
execute(line);
|
||||
offset = 0;
|
||||
} else if (offset < 255) {
|
||||
line[offset++] = chunk[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +196,9 @@ uint64_t main() {
|
||||
memory_set('\b', PROMPT_LENGTH, (char *)bs);
|
||||
memory_set(' ', PROMPT_LENGTH, (char *)ws);
|
||||
|
||||
while (1) {
|
||||
char c;
|
||||
if (read(0, 1, &c)) {
|
||||
on_char_received(c);
|
||||
}
|
||||
char c;
|
||||
while (read(0, 1, &c)) {
|
||||
on_char_received(c);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user