change the child process io buffer to use heap memory

This commit is contained in:
Stephen Toth 2023-09-23 17:32:00 -04:00
parent 5f645c1ea5
commit 072a356d72
1 changed files with 13 additions and 6 deletions

View File

@ -69,11 +69,17 @@ size_t getuserinput(char* input_buffer, size_t max_buffer_size, int fd) {
// go through the buffer and find the lines to be edited and print them after
int processbufferpop(char *roll_buffer, size_t read_length) {
/*for (int i; i<= read_length; i++){
if (roll_buffer[i] = '\n'){
}
}*/
//this is where some optimization could come in with using malloc and then freeing subset of memory; dog garn dynamic memory allocation
int found_index;
char *found_char = strchr(roll_buffer, '\n');
if (found_char != NULL){
found_index = found_char - roll_buffer;
char to_process_string[];
} else {
//no more instances
}
write(STDOUT_FILENO, roll_buffer, read_length);
write(STDOUT_FILENO, "\n", 1);
@ -107,8 +113,9 @@ int main(int argc, char *argv[]) {
}
//remainder is main is the parent process for processing input and shit
char child_out_roll_buffer[BUFCHUNKSIZE+BUFSAFEPAD] = {0};
fcntl(master, F_SETFL, O_NONBLOCK);
char *child_out_roll_buffer = (char*) malloc(sizeof(char) * (BUFCHUNKSIZE+BUFSAFEPAD+1));
usleep(500*1000);
while(1){
// ideally I would want to read from the pipe and buffer the output, rewriting the line on change