0

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

Giuliano69
  • 11
  • 3
  • as stated in the link below the read() and getchar() must wait for the end of line to return, BUT the problem is that... when If I press ctrl-D and then Enter, they DO NOT return... https://stackoverflow.com/questions/1798511/how-to-avoid-pressing-enter-with-getchar-for-reading-a-single-character-only – Giuliano69 Feb 19 '22 at 10:50

0 Answers0