'EOF (Ctrl + D) NOT working when debugging in Eclipse CDT console (year 2022 !!)

February 2022 I'm Using Eclipse 2021.12 + CDT 10.5 + Ubuntu 20.04

Time is passing .. but I'm STILL facing the SAME problems mentioned in 10 year ago messages, with debug of CDT from the console...:

  1. when I debug a CLI program, I cannot send any ctrl+D (or ctrl+z) to the program by the console.
  2. it seems the the options "Connect process input & output to a terminal" is NO MORE available in the config menu of Eclipse/CDT (is it?) ...

Reading with a getchar() or read(), completely IGNORE the ctrl-D...

KINDLY ask:

  • • Are you facing the same problems during debug in CDT ?
  • • Is there a workaround for my configuration ?

Here an example Both reading with getchar and read DO return only after pressing enter, BUT if I perss ctrl-D, the trace debug is lost, and the control never returns to the debug window, even i I enter Enter after having pressed ctrl-D... Seem that ctrl-D on the console terminal get the console stucked ...


int position = 0; // writing buffer position 
int ch;
ch = getchar();
//ch = read(STDIN_FILENO,&ch,1);
while (ch != EOF) {
    (*buffer)[position] = (char) ch;
    position++;
    //printf("ch = %d\n", ch);
    if (buf_len == position) { // buffer full ? double size!
        buf_len *= 2;
        *buffer = realloc(*buffer, buf_len);
        if (buffer == NULL) {
            perror("malloc()");
            exit(EXIT_FAILURE);
        }
    }
    //ch = read(STDIN_FILENO,&ch,1);
    ch = read(STDIN_FILENO, &ch, sizeof(ch));
}
return position;

BR Giuliano



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source